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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user