jwt in headers+localstorage instead of httpOnly cookie (#117)

This commit is contained in:
Marco
2023-12-27 14:32:08 +01:00
committed by GitHub
parent f7ba203ed0
commit c5535fad71
14 changed files with 125 additions and 155 deletions

View File

@@ -69,7 +69,7 @@ export default function Downloaded() {
pushMessage(e, 'error')
navigate('/login')
},
(d) => files$.next(d),
(d) => files$.next(d ?? []),
)
)()

View File

@@ -54,7 +54,7 @@ export default function Login() {
}
const login = async () => {
const task = ffetch(`${url}/auth/login`, {
const task = ffetch<string>(`${url}/auth/login`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
@@ -68,11 +68,15 @@ export default function Login() {
pipe(
task,
matchW(
(l) => {
(error) => {
setFormHasError(true)
pushMessage(l, 'error')
pushMessage(error, 'error')
},
() => navigateAndReload()
(token) => {
console.log(token)
localStorage.setItem('token', token)
navigateAndReload()
}
)
)()
}