mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
M #~: Add logout action when auth user req fails (#2107)
This commit is contained in:
parent
2bc3db4b28
commit
4ca0fa5db9
@ -15,6 +15,7 @@
|
||||
* ------------------------------------------------------------------------- */
|
||||
import { isRejectedWithValue, Middleware, Dispatch } from '@reduxjs/toolkit'
|
||||
|
||||
import authApi from 'client/features/OneApi/auth'
|
||||
import { name as authName, logout } from 'client/features/Auth/slice'
|
||||
import { T, ONEADMIN_GROUP_ID } from 'client/constants'
|
||||
|
||||
@ -26,7 +27,10 @@ export const unauthenticatedMiddleware =
|
||||
({ dispatch }) =>
|
||||
(next) =>
|
||||
(action) => {
|
||||
if (isRejectedWithValue(action) && action.payload.status === 401) {
|
||||
if (
|
||||
authApi.endpoints.getAuthUser.matchRejected(action) ||
|
||||
(isRejectedWithValue(action) && action.payload.status === 401)
|
||||
) {
|
||||
dispatch(logout(T.SessionExpired))
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user