fixes
This commit is contained in:
parent
319ee611fb
commit
4680ea6701
@ -1,6 +1,7 @@
|
||||
import React from "react";
|
||||
|
||||
import { ButtonUi, ButtonUiType } from "../../../../shared/UI/ButtonUi";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
import Form from 'react-bootstrap/Form';
|
||||
|
||||
@ -14,6 +15,8 @@ import styles from "./authLoginForm.module.scss";
|
||||
|
||||
export const AuthLoginFormUi = () => {
|
||||
|
||||
const navigate = useNavigate()
|
||||
|
||||
const schema = yup.object().shape({
|
||||
username: yup.string()
|
||||
.min(3, 'Минимум 3 символа!')
|
||||
@ -47,7 +50,7 @@ export const AuthLoginFormUi = () => {
|
||||
} else {
|
||||
setCookie('authToken', res.data!.authToken)
|
||||
setCookie('refreshToken', res.data!.refreshToken)
|
||||
window.location.replace("/auction")
|
||||
navigate('/auction')
|
||||
}
|
||||
return res.data as AuthResponsePayload
|
||||
})
|
||||
|
@ -6,10 +6,14 @@ export const api = axios.create({
|
||||
headers: {
|
||||
accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': getCookie('authToken') ? `Bearer ${getCookie('authToken')}` : ''
|
||||
},
|
||||
})
|
||||
|
||||
api.interceptors.request.use(config => {
|
||||
config.headers.authorization = getCookie('authToken') ? `Bearer ${getCookie('authToken')}` : ''
|
||||
return config
|
||||
})
|
||||
|
||||
api.interceptors.response.use(undefined, async function (error) {
|
||||
if (error?.response?.status === 401) {
|
||||
removeCookie('authToken')
|
||||
|
Loading…
Reference in New Issue
Block a user