mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
remove NormalizedAuthStatus
This commit is contained in:
@@ -23,7 +23,6 @@ import { EPersonMock } from '../../shared/testing/eperson-mock';
|
||||
import { AppState } from '../../app.reducer';
|
||||
import { ClientCookieService } from '../services/client-cookie.service';
|
||||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||
import { getMockRemoteDataBuildService } from '../../shared/mocks/mock-remote-data-build.service';
|
||||
import { routeServiceStub } from '../../shared/testing/route-service-stub';
|
||||
import { RouteService } from '../services/route.service';
|
||||
import { authMethodsMock } from '../../shared/testing/auth-service-stub';
|
||||
@@ -64,7 +63,7 @@ describe('AuthService test', () => {
|
||||
linkService = {
|
||||
resolveLinks: {}
|
||||
};
|
||||
spyOn(linkService, 'resolveLinks').and.returnValue({authenticated: true, eperson: observableOf({payload: {}})});
|
||||
spyOn(linkService, 'resolveLinks').and.returnValue({ authenticated: true, eperson: observableOf({ payload: {} }) });
|
||||
|
||||
}
|
||||
|
||||
@@ -272,7 +271,7 @@ describe('AuthService test', () => {
|
||||
expect(storage.remove).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it ('should set redirect url to previous page', () => {
|
||||
it('should set redirect url to previous page', () => {
|
||||
spyOn(routeServiceMock, 'getHistory').and.callThrough();
|
||||
spyOn(routerStub, 'navigateByUrl');
|
||||
authService.redirectAfterLoginSuccess(true);
|
||||
@@ -280,7 +279,7 @@ describe('AuthService test', () => {
|
||||
expect(routerStub.navigateByUrl).toHaveBeenCalledWith('/collection/123');
|
||||
});
|
||||
|
||||
it ('should set redirect url to current page', () => {
|
||||
it('should set redirect url to current page', () => {
|
||||
spyOn(routeServiceMock, 'getHistory').and.callThrough();
|
||||
spyOn(routerStub, 'navigateByUrl');
|
||||
authService.redirectAfterLoginSuccess(false);
|
||||
@@ -288,7 +287,7 @@ describe('AuthService test', () => {
|
||||
expect(routerStub.navigateByUrl).toHaveBeenCalledWith('/home');
|
||||
});
|
||||
|
||||
it ('should redirect to / and not to /login', () => {
|
||||
it('should redirect to / and not to /login', () => {
|
||||
spyOn(routeServiceMock, 'getHistory').and.returnValue(observableOf(['/login', '/login']));
|
||||
spyOn(routerStub, 'navigateByUrl');
|
||||
authService.redirectAfterLoginSuccess(true);
|
||||
@@ -296,7 +295,7 @@ describe('AuthService test', () => {
|
||||
expect(routerStub.navigateByUrl).toHaveBeenCalledWith('/');
|
||||
});
|
||||
|
||||
it ('should redirect to / when no redirect url is found', () => {
|
||||
it('should redirect to / when no redirect url is found', () => {
|
||||
spyOn(routeServiceMock, 'getHistory').and.returnValue(observableOf(['']));
|
||||
spyOn(routerStub, 'navigateByUrl');
|
||||
authService.redirectAfterLoginSuccess(true);
|
||||
|
@@ -8,9 +8,9 @@ import { distinctUntilChanged, filter, map, startWith, switchMap, take, withLate
|
||||
import { RouterReducerState } from '@ngrx/router-store';
|
||||
import { select, Store } from '@ngrx/store';
|
||||
import { CookieAttributes } from 'js-cookie';
|
||||
|
||||
import { followLink } from '../../shared/utils/follow-link-config.model';
|
||||
import { LinkService } from '../cache/builders/link.service';
|
||||
|
||||
import { EPerson } from '../eperson/models/eperson.model';
|
||||
import { AuthRequestService } from './auth-request.service';
|
||||
import { HttpOptions } from '../dspace-rest-v2/dspace-rest-v2.service';
|
||||
@@ -27,14 +27,11 @@ import {
|
||||
} 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';
|
||||
import { RouteService } from '../services/route.service';
|
||||
import { AuthMethod } from './models/auth.method';
|
||||
import { NormalizedAuthStatus } from './models/normalized-auth-status.model';
|
||||
|
||||
export const LOGIN_ROUTE = '/login';
|
||||
export const LOGOUT_ROUTE = '/logout';
|
||||
|
||||
export const REDIRECT_COOKIE = 'dsRedirectUrl';
|
||||
|
||||
/**
|
||||
@@ -132,7 +129,7 @@ export class AuthService {
|
||||
options.headers = headers;
|
||||
options.withCredentials = true;
|
||||
return this.authRequestService.getRequest('status', options).pipe(
|
||||
map((status: NormalizedAuthStatus) => Object.assign(new AuthStatus(), status))
|
||||
map((status: AuthStatus) => Object.assign(new AuthStatus(), status))
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -1,17 +1,14 @@
|
||||
|
||||
import {take} from 'rxjs/operators';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, CanActivate, CanLoad, Route, Router, RouterStateSnapshot } from '@angular/router';
|
||||
|
||||
import {Observable, of} from 'rxjs';
|
||||
import { Observable } from 'rxjs';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { select, Store } from '@ngrx/store';
|
||||
|
||||
// reducers
|
||||
import { CoreState } from '../core.reducers';
|
||||
import { isAuthenticated, isAuthenticationLoading } from './selectors';
|
||||
import { isAuthenticated } from './selectors';
|
||||
import { AuthService } from './auth.service';
|
||||
import { RedirectWhenAuthenticationIsRequiredAction } from './auth.actions';
|
||||
import { isEmpty } from '../../shared/empty.util';
|
||||
|
||||
/**
|
||||
* Prevent unauthorized activating and loading of routes
|
||||
@@ -53,7 +50,6 @@ export class AuthenticatedGuard implements CanActivate, CanLoad {
|
||||
}
|
||||
|
||||
private handleAuth(url: string): Observable<boolean> {
|
||||
console.log('authenticated.guard.handleAuth() was called with url: ', url);
|
||||
// get observable
|
||||
const observable = this.store.pipe(select(isAuthenticated));
|
||||
|
||||
|
Reference in New Issue
Block a user