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