changed cookie to localstorage

This commit is contained in:
ACoolName 2023-12-29 13:36:33 +02:00
parent 5ab29611f8
commit 8fb9337270
2 changed files with 3 additions and 3 deletions

View File

@ -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]}>

View File

@ -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) => {