changed cookie to localstorage
This commit is contained in:
parent
5ab29611f8
commit
8fb9337270
@ -82,14 +82,14 @@ console.log(process.env)
|
||||
|
||||
export function ApiWrapper(p: { children: ReactNode}) {
|
||||
const {children} = p
|
||||
const token = Cookies.get('token')
|
||||
const token = localStorage.get('token')
|
||||
if (token) {
|
||||
api.defaults.headers.common.Authorization = `Bearer ${token}`;
|
||||
|
||||
}
|
||||
const [apiAuthenticated, setApiAuthenticated] = useState(Boolean(token))
|
||||
if (!apiAuthenticated) {
|
||||
Cookies.remove('token', { path: '/', domain: 'games.acooldomain.co' })
|
||||
localStorage.remove('token')
|
||||
}
|
||||
const path = useLocation()
|
||||
return (<apiAuthenticatedContext.Provider value={[apiAuthenticated, setApiAuthenticated]}>
|
||||
|
@ -41,7 +41,7 @@ export function LoginPage(props: {}) {
|
||||
fetchToken(username, password, Boolean(data.get('remember'))).then(
|
||||
(token) => {
|
||||
api.defaults.headers.common.Authorization = `Bearer ${token}`;
|
||||
Cookies.set('token', token)
|
||||
localStorage.set('token', token)
|
||||
setApiAuthenticated(true)
|
||||
},
|
||||
(error) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user