maintenance
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
authenticateCredentialsThunk,
|
||||
setError,
|
||||
selectIsAuthenticated,
|
||||
selectIsLoading,
|
||||
selectApplicationId,
|
||||
@@ -17,7 +16,7 @@ export const authenticateRequestMiddleware: Middleware = store => next => async
|
||||
const secret = selectSecret(state);
|
||||
|
||||
console.log(
|
||||
'[authenticateRequest] action [%o] isAuthenticated [%o] isLoading [%o] applicationId [%o] secret [%o]',
|
||||
'[authenticateRequestMiddleware] action [%o] isAuthenticated [%o] isLoading [%o] applicationId [%o] secret [%o]',
|
||||
action,
|
||||
isAuthenticated,
|
||||
isLoading,
|
||||
@@ -31,8 +30,8 @@ export const authenticateRequestMiddleware: Middleware = store => next => async
|
||||
typeof action === 'object' &&
|
||||
action !== null &&
|
||||
'type' in action &&
|
||||
typeof (action as any).type === 'string' &&
|
||||
(action as any).type.startsWith('authentication/')
|
||||
typeof (action as {type: string}).type === 'string' &&
|
||||
(action as {type: string}).type.startsWith('authentication/')
|
||||
) {
|
||||
return next(action);
|
||||
}
|
||||
@@ -57,13 +56,13 @@ export const authenticateRequestMiddleware: Middleware = store => next => async
|
||||
try {
|
||||
console.log('[authenticateRequest] Attempting auto-authentication');
|
||||
// Use the Redux thunk to properly update the state
|
||||
const authResult = await store.dispatch(authenticateCredentialsThunk({applicationId, secret}) as any);
|
||||
const authResult = await store.dispatch(authenticateCredentialsThunk({ applicationId, secret }) as any);
|
||||
|
||||
if (authResult.type.endsWith('/rejected') || authResult.payload === 'Authentication failed') {
|
||||
console.log('[authenticateRequest] Authentication failed');
|
||||
return next(setUnauthorized());
|
||||
}
|
||||
|
||||
|
||||
console.log('[authenticateRequest] Auto-authentication successful, proceeding with action');
|
||||
return next(action);
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user