diff --git a/lib/core/services/auth-guard-ecm.service.spec.ts b/lib/core/services/auth-guard-ecm.service.spec.ts index 59ebbfccd4..42a78586d9 100644 --- a/lib/core/services/auth-guard-ecm.service.spec.ts +++ b/lib/core/services/auth-guard-ecm.service.spec.ts @@ -214,4 +214,62 @@ describe('CanActivateLoggedIn', () => { 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); + }); + }); + }); }); diff --git a/lib/core/services/auth-guard-ecm.service.ts b/lib/core/services/auth-guard-ecm.service.ts index 9bcf07dc6b..3858d305b8 100644 --- a/lib/core/services/auth-guard-ecm.service.ts +++ b/lib/core/services/auth-guard-ecm.service.ts @@ -43,6 +43,10 @@ export class AuthGuardEcm implements CanActivate { .catch(() => false); } + canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise { + return this.canActivate(route, state); + } + canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise { return this.isLoggedIn().then(isLoggedIn => {