fix: perform logout if the silent refresh attempt fails (#3705)

Co-authored-by: Dmitry Mukovkin <d.mukovkin@cft.ru>
Co-authored-by: jamesgeorge007 <jamesgeorge998001@gmail.com>
This commit is contained in:
Dmitry
2024-01-23 23:23:59 +07:00
committed by GitHub
parent 99f5070f71
commit d1f6f40ef8

View File

@@ -114,6 +114,7 @@ async function setInitialUser() {
} else {
setUser(null)
isGettingInitialUser.value = false
await logout()
}
return
@@ -146,22 +147,26 @@ async function setInitialUser() {
}
async function refreshToken() {
const res = await axios.get(
`${import.meta.env.VITE_BACKEND_API_URL}/auth/refresh`,
{
withCredentials: true,
try {
const res = await axios.get(
`${import.meta.env.VITE_BACKEND_API_URL}/auth/refresh`,
{
withCredentials: true,
}
)
const isSuccessful = res.status === 200
if (isSuccessful) {
authEvents$.next({
event: "token_refresh",
})
}
)
const isSuccessful = res.status === 200
if (isSuccessful) {
authEvents$.next({
event: "token_refresh",
})
return isSuccessful
} catch (error) {
return false
}
return isSuccessful
}
async function sendMagicLink(email: string) {