mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
remove other PR code
This commit is contained in:
parent
0c9726049a
commit
aba7095d3d
@ -29,7 +29,6 @@ import {
|
||||
AppConfigValues
|
||||
} from '../app-config/app-config.service';
|
||||
import { OauthConfigModel } from '../models/oauth-config.model';
|
||||
import { MatDialog } from '@angular/material';
|
||||
|
||||
export abstract class AuthGuardBase implements CanActivate, CanActivateChild {
|
||||
abstract checkLogin(
|
||||
@ -47,21 +46,14 @@ export abstract class AuthGuardBase implements CanActivate, CanActivateChild {
|
||||
constructor(
|
||||
protected authenticationService: AuthenticationService,
|
||||
protected router: Router,
|
||||
protected appConfigService: AppConfigService,
|
||||
protected dialog: MatDialog
|
||||
protected appConfigService: AppConfigService
|
||||
) {}
|
||||
|
||||
canActivate(
|
||||
route: ActivatedRouteSnapshot,
|
||||
state: RouterStateSnapshot
|
||||
): Observable<boolean> | Promise<boolean> | boolean {
|
||||
const checkLogin = this.checkLogin(route, state.url);
|
||||
|
||||
if (!checkLogin) {
|
||||
this.dialog.closeAll();
|
||||
}
|
||||
|
||||
return checkLogin;
|
||||
return this.checkLogin(route, state.url);
|
||||
}
|
||||
|
||||
canActivateChild(
|
||||
|
@ -22,7 +22,6 @@ import { AuthenticationService } from './authentication.service';
|
||||
import { RouterStateSnapshot, Router } from '@angular/router';
|
||||
import { setupTestBed } from '../testing/setupTestBed';
|
||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||
import { MatDialog } from '@angular/material';
|
||||
|
||||
describe('AuthGuardService BPM', () => {
|
||||
|
||||
@ -157,21 +156,4 @@ describe('AuthGuardService BPM', () => {
|
||||
expect(router.navigateByUrl).toHaveBeenCalledWith('/fakeLoginRoute?redirectUrl=some-url');
|
||||
}));
|
||||
|
||||
it('should to close the material dialog if is redirect to the login', () => {
|
||||
const materialDialog = TestBed.get(MatDialog);
|
||||
|
||||
spyOn(materialDialog, 'closeAll');
|
||||
|
||||
spyOn(authService, 'setRedirect').and.callThrough();
|
||||
spyOn(router, 'navigateByUrl').and.stub();
|
||||
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
|
||||
|
||||
authGuard.canActivate(null, route);
|
||||
|
||||
expect(authService.setRedirect).toHaveBeenCalledWith({
|
||||
provider: 'BPM', url: 'some-url'
|
||||
});
|
||||
|
||||
expect(materialDialog.closeAll).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
@ -21,7 +21,6 @@ import { AppConfigService } from '../app-config/app-config.service';
|
||||
import { AuthenticationService } from './authentication.service';
|
||||
import { AuthGuardBase } from './auth-guard-base';
|
||||
import { Observable } from 'rxjs';
|
||||
import { MatDialog } from '@angular/material';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@ -30,10 +29,8 @@ export class AuthGuardBpm extends AuthGuardBase {
|
||||
|
||||
constructor(authenticationService: AuthenticationService,
|
||||
router: Router,
|
||||
appConfigService: AppConfigService,
|
||||
dialog: MatDialog
|
||||
) {
|
||||
super(authenticationService, router, appConfigService, dialog);
|
||||
appConfigService: AppConfigService) {
|
||||
super(authenticationService, router, appConfigService);
|
||||
}
|
||||
|
||||
checkLogin(_: ActivatedRouteSnapshot, redirectUrl: string): Observable<boolean> | Promise<boolean> | boolean {
|
||||
|
@ -22,7 +22,6 @@ import { AuthenticationService } from './authentication.service';
|
||||
import { RouterStateSnapshot, Router } from '@angular/router';
|
||||
import { setupTestBed } from '../testing/setupTestBed';
|
||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||
import { MatDialog } from '@angular/material';
|
||||
|
||||
describe('AuthGuardService ECM', () => {
|
||||
|
||||
@ -157,22 +156,4 @@ describe('AuthGuardService ECM', () => {
|
||||
expect(router.navigateByUrl).toHaveBeenCalledWith('/fakeLoginRoute?redirectUrl=some-url');
|
||||
}));
|
||||
|
||||
it('should to close the material dialog if is redirect to the login', () => {
|
||||
const materialDialog = TestBed.get(MatDialog);
|
||||
|
||||
spyOn(materialDialog, 'closeAll');
|
||||
|
||||
spyOn(authService, 'setRedirect').and.callThrough();
|
||||
spyOn(router, 'navigateByUrl').and.stub();
|
||||
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
|
||||
|
||||
authGuard.canActivate(null, route);
|
||||
|
||||
expect(authService.setRedirect).toHaveBeenCalledWith({
|
||||
provider: 'ECM', url: 'some-url'
|
||||
});
|
||||
|
||||
expect(materialDialog.closeAll).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -23,7 +23,6 @@ import { AuthenticationService } from './authentication.service';
|
||||
import { AppConfigService } from '../app-config/app-config.service';
|
||||
import { AuthGuardBase } from './auth-guard-base';
|
||||
import { Observable } from 'rxjs';
|
||||
import { MatDialog } from '@angular/material';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@ -32,9 +31,8 @@ export class AuthGuardEcm extends AuthGuardBase {
|
||||
|
||||
constructor(authenticationService: AuthenticationService,
|
||||
router: Router,
|
||||
appConfigService: AppConfigService,
|
||||
dialog: MatDialog) {
|
||||
super(authenticationService, router, appConfigService, dialog);
|
||||
appConfigService: AppConfigService) {
|
||||
super(authenticationService, router, appConfigService);
|
||||
}
|
||||
|
||||
checkLogin(_: ActivatedRouteSnapshot, redirectUrl: string): Observable<boolean> | Promise<boolean> | boolean {
|
||||
|
@ -21,7 +21,6 @@ import { setupTestBed } from '../testing/setupTestBed';
|
||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||
import { AuthGuardSsoRoleService } from './auth-guard-sso-role.service';
|
||||
import { JwtHelperService } from './jwt-helper.service';
|
||||
import { MatDialog } from '@angular/material';
|
||||
|
||||
describe('Auth Guard SSO role service', () => {
|
||||
|
||||
@ -165,20 +164,4 @@ describe('Auth Guard SSO role service', () => {
|
||||
|
||||
expect(authGuard.canActivate(route)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('Should canActivate be false hasRealm is true and hasClientRole is false', () => {
|
||||
const materialDialog = TestBed.get(MatDialog);
|
||||
|
||||
spyOn(materialDialog, 'closeAll');
|
||||
|
||||
const route: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
|
||||
spyOn(jwtHelperService, 'hasRealmRoles').and.returnValue(true);
|
||||
spyOn(jwtHelperService, 'hasRealmRolesForClientRole').and.returnValue(false);
|
||||
|
||||
route.params = { appName: 'fakeapp' };
|
||||
route.data = { 'clientRoles': ['appName'], 'roles': ['role1', 'role2'] };
|
||||
|
||||
expect(materialDialog.closeAll).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -22,7 +22,6 @@ import { Observable } from 'rxjs';
|
||||
import { AppConfigService } from '../app-config/app-config.service';
|
||||
import { AuthGuardBase } from './auth-guard-base';
|
||||
import { JwtHelperService } from './jwt-helper.service';
|
||||
import { MatDialog } from '@angular/material';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@ -34,9 +33,8 @@ export class AuthGuard extends AuthGuardBase {
|
||||
constructor(private jwtHelperService: JwtHelperService,
|
||||
authenticationService: AuthenticationService,
|
||||
router: Router,
|
||||
appConfigService: AppConfigService,
|
||||
dialog: MatDialog) {
|
||||
super(authenticationService, router, appConfigService, dialog);
|
||||
appConfigService: AppConfigService) {
|
||||
super(authenticationService, router, appConfigService);
|
||||
this.ticketChangeBind = this.ticketChange.bind(this);
|
||||
|
||||
window.addEventListener('storage', this.ticketChangeBind);
|
||||
|
Loading…
x
Reference in New Issue
Block a user