mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-08-15 16:22:25 +02:00
Fix inactivity detection followed by logout - Fixes #267
This commit is contained in:
18
resources/js/services/httpClientFactory.js
vendored
18
resources/js/services/httpClientFactory.js
vendored
@ -51,6 +51,15 @@ export const httpClientFactory = (endpoint = 'api') => {
|
||||
await axios.get('/refresh-csrf')
|
||||
return httpClient.request(originalRequestConfig)
|
||||
}
|
||||
|
||||
// api calls are stateless so when user inactivity is detected
|
||||
// by the backend middleware, it cannot logout the user directly
|
||||
// so it returns a 418 response.
|
||||
// We catch the 418 response and log the user out
|
||||
if (error.response.status === 418) {
|
||||
const user = useUserStore()
|
||||
user.logout({ kicked: true})
|
||||
}
|
||||
|
||||
if (error.response && [407].includes(error.response.status)) {
|
||||
useNotifyStore().error(error)
|
||||
@ -78,15 +87,6 @@ export const httpClientFactory = (endpoint = 'api') => {
|
||||
return new Promise(() => {})
|
||||
}
|
||||
|
||||
// api calls are stateless so when user inactivity is detected
|
||||
// by the backend middleware, it cannot logout the user directly
|
||||
// so it returns a 418 response.
|
||||
// We catch the 418 response and log the user out
|
||||
if (error.response.status === 418) {
|
||||
const user = useUserStore()
|
||||
user.logout({ kicked: true})
|
||||
}
|
||||
|
||||
useNotifyStore().error(error)
|
||||
return new Promise(() => {})
|
||||
}
|
||||
|
Reference in New Issue
Block a user