mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
Removed isStandAlone from store
This commit is contained in:
@@ -28,9 +28,8 @@ import {
|
||||
RegistrationErrorAction,
|
||||
RegistrationSuccessAction,
|
||||
RetrieveAuthMethodsAction,
|
||||
RetrieveAuthMethodsErrorAction,
|
||||
RetrieveAuthMethodsSuccessAction,
|
||||
GetJWTafterShibbLoginAction, StartShibbolethAuthenticationAction
|
||||
GetJWTafterShibbLoginAction, StartShibbolethAuthenticationAction, RetrieveAuthMethodsErrorAction
|
||||
} from './auth.actions';
|
||||
import { EPerson } from '../eperson/models/eperson.model';
|
||||
import { AuthStatus } from './models/auth-status.model';
|
||||
@@ -76,79 +75,79 @@ export class AuthEffects {
|
||||
|
||||
@Effect()
|
||||
public authenticateSuccess$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(AuthActionTypes.AUTHENTICATE_SUCCESS),
|
||||
tap((action: AuthenticationSuccessAction) => this.authService.storeToken(action.payload)),
|
||||
map((action: AuthenticationSuccessAction) => new AuthenticatedAction(action.payload))
|
||||
);
|
||||
ofType(AuthActionTypes.AUTHENTICATE_SUCCESS),
|
||||
tap((action: AuthenticationSuccessAction) => this.authService.storeToken(action.payload)),
|
||||
map((action: AuthenticationSuccessAction) => new AuthenticatedAction(action.payload))
|
||||
);
|
||||
|
||||
@Effect()
|
||||
public authenticated$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(AuthActionTypes.AUTHENTICATED),
|
||||
switchMap((action: AuthenticatedAction) => {
|
||||
return this.authService.authenticatedUser(action.payload).pipe(
|
||||
map((user: EPerson) => new AuthenticatedSuccessAction((user !== null), action.payload, user)),
|
||||
catchError((error) => observableOf(new AuthenticatedErrorAction(error))),);
|
||||
})
|
||||
);
|
||||
ofType(AuthActionTypes.AUTHENTICATED),
|
||||
switchMap((action: AuthenticatedAction) => {
|
||||
return this.authService.authenticatedUser(action.payload).pipe(
|
||||
map((user: EPerson) => new AuthenticatedSuccessAction((user !== null), action.payload, user)),
|
||||
catchError((error) => observableOf(new AuthenticatedErrorAction(error))),);
|
||||
})
|
||||
);
|
||||
|
||||
// It means "reacts to this action but don't send another"
|
||||
@Effect({ dispatch: false })
|
||||
@Effect({dispatch: false})
|
||||
public authenticatedError$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(AuthActionTypes.AUTHENTICATED_ERROR),
|
||||
tap((action: LogOutSuccessAction) => this.authService.removeToken())
|
||||
);
|
||||
ofType(AuthActionTypes.AUTHENTICATED_ERROR),
|
||||
tap((action: LogOutSuccessAction) => this.authService.removeToken())
|
||||
);
|
||||
|
||||
@Effect()
|
||||
public checkToken$: Observable<Action> = this.actions$.pipe(ofType(AuthActionTypes.CHECK_AUTHENTICATION_TOKEN),
|
||||
switchMap(() => {
|
||||
return this.authService.hasValidAuthenticationToken().pipe(
|
||||
map((token: AuthTokenInfo) => new AuthenticatedAction(token)),
|
||||
catchError((error) => observableOf(new CheckAuthenticationTokenErrorAction()))
|
||||
);
|
||||
})
|
||||
);
|
||||
switchMap(() => {
|
||||
return this.authService.hasValidAuthenticationToken().pipe(
|
||||
map((token: AuthTokenInfo) => new AuthenticatedAction(token)),
|
||||
catchError((error) => observableOf(new CheckAuthenticationTokenErrorAction()))
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
@Effect()
|
||||
public checkTokenError$: Observable<Action> = this.actions$
|
||||
.pipe(
|
||||
ofType(AuthActionTypes.CHECK_AUTHENTICATION_TOKEN_ERROR),
|
||||
map(() => new RetrieveAuthMethodsAction())
|
||||
ofType(AuthActionTypes.CHECK_AUTHENTICATION_TOKEN_ERROR),
|
||||
map(() => new RetrieveAuthMethodsAction())
|
||||
)
|
||||
|
||||
@Effect()
|
||||
public createUser$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(AuthActionTypes.REGISTRATION),
|
||||
debounceTime(500), // to remove when functionality is implemented
|
||||
switchMap((action: RegistrationAction) => {
|
||||
return this.authService.create(action.payload).pipe(
|
||||
map((user: EPerson) => new RegistrationSuccessAction(user)),
|
||||
catchError((error) => observableOf(new RegistrationErrorAction(error)))
|
||||
);
|
||||
})
|
||||
);
|
||||
ofType(AuthActionTypes.REGISTRATION),
|
||||
debounceTime(500), // to remove when functionality is implemented
|
||||
switchMap((action: RegistrationAction) => {
|
||||
return this.authService.create(action.payload).pipe(
|
||||
map((user: EPerson) => new RegistrationSuccessAction(user)),
|
||||
catchError((error) => observableOf(new RegistrationErrorAction(error)))
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
@Effect()
|
||||
public refreshToken$: Observable<Action> = this.actions$.pipe(ofType(AuthActionTypes.REFRESH_TOKEN),
|
||||
switchMap((action: RefreshTokenAction) => {
|
||||
return this.authService.refreshAuthenticationToken(action.payload).pipe(
|
||||
map((token: AuthTokenInfo) => new RefreshTokenSuccessAction(token)),
|
||||
catchError((error) => observableOf(new RefreshTokenErrorAction()))
|
||||
);
|
||||
})
|
||||
);
|
||||
switchMap((action: RefreshTokenAction) => {
|
||||
return this.authService.refreshAuthenticationToken(action.payload).pipe(
|
||||
map((token: AuthTokenInfo) => new RefreshTokenSuccessAction(token)),
|
||||
catchError((error) => observableOf(new RefreshTokenErrorAction()))
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
// It means "reacts to this action but don't send another"
|
||||
@Effect({ dispatch: false })
|
||||
@Effect({dispatch: false})
|
||||
public refreshTokenSuccess$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(AuthActionTypes.REFRESH_TOKEN_SUCCESS),
|
||||
tap((action: RefreshTokenSuccessAction) => this.authService.replaceToken(action.payload))
|
||||
);
|
||||
ofType(AuthActionTypes.REFRESH_TOKEN_SUCCESS),
|
||||
tap((action: RefreshTokenSuccessAction) => this.authService.replaceToken(action.payload))
|
||||
);
|
||||
|
||||
/**
|
||||
* When the store is rehydrated in the browser,
|
||||
* clear a possible invalid token or authentication errors
|
||||
*/
|
||||
@Effect({ dispatch: false })
|
||||
@Effect({dispatch: false})
|
||||
public clearInvalidTokenOnRehydrate$: Observable<any> = this.actions$.pipe(
|
||||
ofType(StoreActionTypes.REHYDRATE),
|
||||
switchMap(() => {
|
||||
@@ -173,7 +172,7 @@ export class AuthEffects {
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
@Effect({dispatch: false})
|
||||
public logOutSuccess$: Observable<Action> = this.actions$
|
||||
.pipe(ofType(AuthActionTypes.LOG_OUT_SUCCESS),
|
||||
tap(() => this.authService.removeToken()),
|
||||
@@ -181,14 +180,14 @@ export class AuthEffects {
|
||||
tap(() => this.authService.refreshAfterLogout())
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
@Effect({dispatch: false})
|
||||
public redirectToLogin$: Observable<Action> = this.actions$
|
||||
.pipe(ofType(AuthActionTypes.REDIRECT_AUTHENTICATION_REQUIRED),
|
||||
tap(() => this.authService.removeToken()),
|
||||
tap(() => this.authService.redirectToLogin())
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
@Effect({dispatch: false})
|
||||
public redirectToLoginTokenExpired$: Observable<Action> = this.actions$
|
||||
.pipe(
|
||||
ofType(AuthActionTypes.REDIRECT_TOKEN_EXPIRED),
|
||||
@@ -201,12 +200,12 @@ export class AuthEffects {
|
||||
.pipe(
|
||||
ofType(AuthActionTypes.RETRIEVE_AUTH_METHODS),
|
||||
switchMap(() => {
|
||||
return this.authService.retrieveAuthMethods()
|
||||
.pipe(
|
||||
map((location: any) => new RetrieveAuthMethodsSuccessAction(location)),
|
||||
catchError((error) => observableOf(new RetrieveAuthMethodsErrorAction()))
|
||||
)
|
||||
})
|
||||
return this.authService.retrieveAuthMethods()
|
||||
.pipe(
|
||||
map((location: any) => new RetrieveAuthMethodsSuccessAction(location)),
|
||||
catchError((error) => observableOf(new RetrieveAuthMethodsErrorAction()))
|
||||
)
|
||||
})
|
||||
)
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user