mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
canActivateChild implementation (#2691)
This commit is contained in:
committed by
Eugenio Romano
parent
4fbd9f5d62
commit
39737b3df6
@@ -214,4 +214,62 @@ describe('CanActivateLoggedIn', () => {
|
|||||||
expect(this.auth.setRedirectUrl).toHaveBeenCalledWith('some-url');
|
expect(this.auth.setRedirectUrl).toHaveBeenCalledWith('some-url');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('canActivateChild', () => {
|
||||||
|
describe('user is not logged in', () => {
|
||||||
|
beforeEach(async(() => {
|
||||||
|
this.test = new TestConfig({
|
||||||
|
isLoggedIn: false
|
||||||
|
});
|
||||||
|
|
||||||
|
const { guard } = this.test;
|
||||||
|
|
||||||
|
guard.canActivateChild(null, { url: '' }).then((activate) => {
|
||||||
|
this.activate = activate;
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should not allow route to activate', () => {
|
||||||
|
expect(this.activate).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('user is logged in but ticket is invalid', () => {
|
||||||
|
beforeEach(async(() => {
|
||||||
|
this.test = new TestConfig({
|
||||||
|
isLoggedIn: true,
|
||||||
|
validateTicket: false
|
||||||
|
});
|
||||||
|
|
||||||
|
const { guard } = this.test;
|
||||||
|
|
||||||
|
guard.canActivateChild(null, { url: '' }).then((activate) => {
|
||||||
|
this.activate = activate;
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should not allow route to activate', () => {
|
||||||
|
expect(this.activate).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('user is logged in and ticket is valid', () => {
|
||||||
|
beforeEach(async(() => {
|
||||||
|
this.test = new TestConfig({
|
||||||
|
isLoggedIn: true,
|
||||||
|
validateTicket: true
|
||||||
|
});
|
||||||
|
|
||||||
|
const { guard } = this.test;
|
||||||
|
|
||||||
|
guard.canActivateChild(null, { url: '' }).then((activate) => {
|
||||||
|
this.activate = activate;
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should allow route to activate', () => {
|
||||||
|
expect(this.activate).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -43,6 +43,10 @@ export class AuthGuardEcm implements CanActivate {
|
|||||||
.catch(() => false);
|
.catch(() => false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
|
||||||
|
return this.canActivate(route, state);
|
||||||
|
}
|
||||||
|
|
||||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
|
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
|
||||||
|
|
||||||
return this.isLoggedIn().then(isLoggedIn => {
|
return this.isLoggedIn().then(isLoggedIn => {
|
||||||
|
Reference in New Issue
Block a user