Added CHECK_AUTHENTICATION_TOKEN_COOKIE action

This commit is contained in:
Giuseppe Digilio
2019-10-24 22:46:01 +02:00
parent 24b308ace6
commit 1896b14520
8 changed files with 131 additions and 127 deletions

View File

@@ -18,7 +18,11 @@ import { isEmpty, isNotEmpty, isNotNull, isNotUndefined } from '../../shared/emp
import { CookieService } from '../services/cookie.service';
import { getAuthenticationToken, getRedirectUrl, isAuthenticated, isTokenRefreshing } from './selectors';
import { AppState, routerStateSelector } from '../../app.reducer';
import { ResetAuthenticationMessagesAction, SetRedirectUrlAction } from './auth.actions';
import {
CheckAuthenticationTokenAction,
ResetAuthenticationMessagesAction,
SetRedirectUrlAction
} from './auth.actions';
import { NativeWindowRef, NativeWindowService } from '../services/window.service';
import { Base64EncodeUrl } from '../../shared/utils/encode-decode.util';
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
@@ -115,17 +119,11 @@ export class AuthService {
}
public startShibbAuth(): Observable<AuthStatus> {
return this.authRequestService.postToEndpoint('login').pipe(
map((status: AuthStatus) => {
if (status.authenticated) {
return status;
} else {
throw(new Error('Shibboleth login failed'));
}
}))
/**
* Checks if token is present into the request cookie
*/
public checkAuthenticationCookie(): Observable<AuthStatus> {
return this.authRequestService.postToEndpoint('login');
}
/**
@@ -162,7 +160,7 @@ export class AuthService {
* Checks if token is present into browser storage and is valid. (NB Check is done only on SSR)
*/
public checkAuthenticationToken() {
return
this.store.dispatch(new CheckAuthenticationTokenAction());
}
/**
@@ -215,16 +213,12 @@ export class AuthService {
* Retrieve authentication methods available
* @returns {User}
*/
public retrieveAuthMethods(): Observable<AuthMethodModel[]> {
return this.authRequestService.postToEndpoint('login', {}).pipe(
map((status: AuthStatus) => {
let authMethods: AuthMethodModel[];
if (isNotEmpty(status.authMethods)) {
authMethods = status.authMethods;
}
return authMethods;
})
)
public retrieveAuthMethods(status: AuthStatus): Observable<AuthMethodModel[]> {
let authMethods: AuthMethodModel[] = [];
if (isNotEmpty(status.authMethods)) {
authMethods = status.authMethods;
}
return observableOf(authMethods);
}
/**