1
0
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:
Sergio Betanzos 2022-05-31 10:31:11 +02:00 committed by GitHub
parent 2bc3db4b28
commit 4ca0fa5db9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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))
}