From 6b821e3a5680d4aa22ce9a1f70f813a8cce223a8 Mon Sep 17 00:00:00 2001 From: Oliver Cooper Date: Mon, 11 Jan 2021 17:57:25 +0000 Subject: [PATCH 1/2] angular: Fix AuthGuard returning 'true' when user not authorized. --- npm/ng-packs/packages/core/src/lib/guards/auth.guard.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/ng-packs/packages/core/src/lib/guards/auth.guard.ts b/npm/ng-packs/packages/core/src/lib/guards/auth.guard.ts index acd7417560e..c95b890239b 100644 --- a/npm/ng-packs/packages/core/src/lib/guards/auth.guard.ts +++ b/npm/ng-packs/packages/core/src/lib/guards/auth.guard.ts @@ -17,6 +17,6 @@ export class AuthGuard implements CanActivate { } this.authService.initLogin(); - return true; + return false; } } From 50be0e4ab368a8111343835cb9cbd0938470effc Mon Sep 17 00:00:00 2001 From: Oliver Cooper Date: Mon, 11 Jan 2021 18:24:04 +0000 Subject: [PATCH 2/2] angular: Update AuthGuard test --- npm/ng-packs/packages/core/src/lib/tests/auth.guard.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/ng-packs/packages/core/src/lib/tests/auth.guard.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/auth.guard.spec.ts index 18bf53ede8a..f34f5032278 100644 --- a/npm/ng-packs/packages/core/src/lib/tests/auth.guard.spec.ts +++ b/npm/ng-packs/packages/core/src/lib/tests/auth.guard.spec.ts @@ -26,7 +26,7 @@ describe('AuthGuard', () => { spectator.inject(OAuthService).hasValidAccessToken.andReturn(false); const initLoginSpy = jest.spyOn(authService, 'initLogin'); - expect(guard.canActivate()).toBe(true); + expect(guard.canActivate()).toBe(false); expect(initLoginSpy).toHaveBeenCalled(); }); });