From 5186a61b2212e4ee11a4e96f71083c10f58fcace Mon Sep 17 00:00:00 2001 From: Louis Zuckerman Date: Fri, 28 Jul 2017 19:36:22 -0400 Subject: [PATCH] spira/angular-jwt-auth#66 refresh token if cookie is enabled but missing --- src/service/ngJwtAuthService.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/service/ngJwtAuthService.ts b/src/service/ngJwtAuthService.ts index 9f8a3cb..3338c35 100644 --- a/src/service/ngJwtAuthService.ts +++ b/src/service/ngJwtAuthService.ts @@ -135,7 +135,15 @@ export class NgJwtAuthService { ; //needs to refresh if the the next time we could refresh is after the configured refresh before date - return (latestRefresh <= nextRefreshOpportunity); + return (latestRefresh <= nextRefreshOpportunity || this.cookieIsMissing()); + } + + /** + * Check if there should be a cookie, but it is missing + * @returns {boolean} + */ + private cookieIsMissing():boolean { + return this.config.cookie.enabled && !this.$cookies.get(this.config.cookie.name); } /**