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
|
AppConfigValues
|
||||||
} from '../app-config/app-config.service';
|
} from '../app-config/app-config.service';
|
||||||
import { OauthConfigModel } from '../models/oauth-config.model';
|
import { OauthConfigModel } from '../models/oauth-config.model';
|
||||||
import { MatDialog } from '@angular/material';
|
|
||||||
|
|
||||||
export abstract class AuthGuardBase implements CanActivate, CanActivateChild {
|
export abstract class AuthGuardBase implements CanActivate, CanActivateChild {
|
||||||
abstract checkLogin(
|
abstract checkLogin(
|
||||||
@ -47,21 +46,14 @@ export abstract class AuthGuardBase implements CanActivate, CanActivateChild {
|
|||||||
constructor(
|
constructor(
|
||||||
protected authenticationService: AuthenticationService,
|
protected authenticationService: AuthenticationService,
|
||||||
protected router: Router,
|
protected router: Router,
|
||||||
protected appConfigService: AppConfigService,
|
protected appConfigService: AppConfigService
|
||||||
protected dialog: MatDialog
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
canActivate(
|
canActivate(
|
||||||
route: ActivatedRouteSnapshot,
|
route: ActivatedRouteSnapshot,
|
||||||
state: RouterStateSnapshot
|
state: RouterStateSnapshot
|
||||||
): Observable<boolean> | Promise<boolean> | boolean {
|
): Observable<boolean> | Promise<boolean> | boolean {
|
||||||
const checkLogin = this.checkLogin(route, state.url);
|
return this.checkLogin(route, state.url);
|
||||||
|
|
||||||
if (!checkLogin) {
|
|
||||||
this.dialog.closeAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
return checkLogin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
canActivateChild(
|
canActivateChild(
|
||||||
|
@ -22,7 +22,6 @@ import { AuthenticationService } from './authentication.service';
|
|||||||
import { RouterStateSnapshot, Router } from '@angular/router';
|
import { RouterStateSnapshot, Router } from '@angular/router';
|
||||||
import { setupTestBed } from '../testing/setupTestBed';
|
import { setupTestBed } from '../testing/setupTestBed';
|
||||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||||
import { MatDialog } from '@angular/material';
|
|
||||||
|
|
||||||
describe('AuthGuardService BPM', () => {
|
describe('AuthGuardService BPM', () => {
|
||||||
|
|
||||||
@ -157,21 +156,4 @@ describe('AuthGuardService BPM', () => {
|
|||||||
expect(router.navigateByUrl).toHaveBeenCalledWith('/fakeLoginRoute?redirectUrl=some-url');
|
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 { AuthenticationService } from './authentication.service';
|
||||||
import { AuthGuardBase } from './auth-guard-base';
|
import { AuthGuardBase } from './auth-guard-base';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { MatDialog } from '@angular/material';
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -30,10 +29,8 @@ export class AuthGuardBpm extends AuthGuardBase {
|
|||||||
|
|
||||||
constructor(authenticationService: AuthenticationService,
|
constructor(authenticationService: AuthenticationService,
|
||||||
router: Router,
|
router: Router,
|
||||||
appConfigService: AppConfigService,
|
appConfigService: AppConfigService) {
|
||||||
dialog: MatDialog
|
super(authenticationService, router, appConfigService);
|
||||||
) {
|
|
||||||
super(authenticationService, router, appConfigService, dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
checkLogin(_: ActivatedRouteSnapshot, redirectUrl: string): Observable<boolean> | Promise<boolean> | boolean {
|
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 { RouterStateSnapshot, Router } from '@angular/router';
|
||||||
import { setupTestBed } from '../testing/setupTestBed';
|
import { setupTestBed } from '../testing/setupTestBed';
|
||||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||||
import { MatDialog } from '@angular/material';
|
|
||||||
|
|
||||||
describe('AuthGuardService ECM', () => {
|
describe('AuthGuardService ECM', () => {
|
||||||
|
|
||||||
@ -157,22 +156,4 @@ describe('AuthGuardService ECM', () => {
|
|||||||
expect(router.navigateByUrl).toHaveBeenCalledWith('/fakeLoginRoute?redirectUrl=some-url');
|
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 { AppConfigService } from '../app-config/app-config.service';
|
||||||
import { AuthGuardBase } from './auth-guard-base';
|
import { AuthGuardBase } from './auth-guard-base';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { MatDialog } from '@angular/material';
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -32,9 +31,8 @@ export class AuthGuardEcm extends AuthGuardBase {
|
|||||||
|
|
||||||
constructor(authenticationService: AuthenticationService,
|
constructor(authenticationService: AuthenticationService,
|
||||||
router: Router,
|
router: Router,
|
||||||
appConfigService: AppConfigService,
|
appConfigService: AppConfigService) {
|
||||||
dialog: MatDialog) {
|
super(authenticationService, router, appConfigService);
|
||||||
super(authenticationService, router, appConfigService, dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
checkLogin(_: ActivatedRouteSnapshot, redirectUrl: string): Observable<boolean> | Promise<boolean> | boolean {
|
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 { CoreTestingModule } from '../testing/core.testing.module';
|
||||||
import { AuthGuardSsoRoleService } from './auth-guard-sso-role.service';
|
import { AuthGuardSsoRoleService } from './auth-guard-sso-role.service';
|
||||||
import { JwtHelperService } from './jwt-helper.service';
|
import { JwtHelperService } from './jwt-helper.service';
|
||||||
import { MatDialog } from '@angular/material';
|
|
||||||
|
|
||||||
describe('Auth Guard SSO role service', () => {
|
describe('Auth Guard SSO role service', () => {
|
||||||
|
|
||||||
@ -165,20 +164,4 @@ describe('Auth Guard SSO role service', () => {
|
|||||||
|
|
||||||
expect(authGuard.canActivate(route)).toBeFalsy();
|
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 { AppConfigService } from '../app-config/app-config.service';
|
||||||
import { AuthGuardBase } from './auth-guard-base';
|
import { AuthGuardBase } from './auth-guard-base';
|
||||||
import { JwtHelperService } from './jwt-helper.service';
|
import { JwtHelperService } from './jwt-helper.service';
|
||||||
import { MatDialog } from '@angular/material';
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -34,9 +33,8 @@ export class AuthGuard extends AuthGuardBase {
|
|||||||
constructor(private jwtHelperService: JwtHelperService,
|
constructor(private jwtHelperService: JwtHelperService,
|
||||||
authenticationService: AuthenticationService,
|
authenticationService: AuthenticationService,
|
||||||
router: Router,
|
router: Router,
|
||||||
appConfigService: AppConfigService,
|
appConfigService: AppConfigService) {
|
||||||
dialog: MatDialog) {
|
super(authenticationService, router, appConfigService);
|
||||||
super(authenticationService, router, appConfigService, dialog);
|
|
||||||
this.ticketChangeBind = this.ticketChange.bind(this);
|
this.ticketChangeBind = this.ticketChange.bind(this);
|
||||||
|
|
||||||
window.addEventListener('storage', this.ticketChangeBind);
|
window.addEventListener('storage', this.ticketChangeBind);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user