From 42233567c2f93d50666649755d88e789ceffcace Mon Sep 17 00:00:00 2001 From: Nipun Thennakoon Date: Wed, 6 Jul 2022 19:04:13 +0530 Subject: [PATCH 1/2] Fix the login loop when signing in after configuring angular router. --- .../components/asgardeo-sign-in-redirect.component.ts | 5 ++++- lib/src/services/asgardeo-navigator.service.ts | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/src/components/asgardeo-sign-in-redirect.component.ts b/lib/src/components/asgardeo-sign-in-redirect.component.ts index 2416004..422dbf0 100644 --- a/lib/src/components/asgardeo-sign-in-redirect.component.ts +++ b/lib/src/components/asgardeo-sign-in-redirect.component.ts @@ -21,6 +21,7 @@ import { Component, OnInit } from "@angular/core"; import { Hooks } from "../models/asgardeo-spa.models"; import { AsgardeoAuthService } from "../services/asgardeo-auth.service"; import { AsgardeoNavigatorService } from "../services/asgardeo-navigator.service"; +import {SPAUtils} from "@asgardeo/auth-spa"; @Component({ selector: "lib-asgardeo-sign-in-redirect", @@ -34,6 +35,8 @@ export class AsgardeoSignInRedirectComponent implements OnInit { this.navigator.navigateByUrl(this.navigator.getRedirectUrl()); }); - this.auth.signIn(); + if (!SPAUtils.hasAuthSearchParamsInURL(this.navigator.getCurrentUrl())) { + this.auth.signIn(); + } } } diff --git a/lib/src/services/asgardeo-navigator.service.ts b/lib/src/services/asgardeo-navigator.service.ts index 79ebd63..78b5cad 100644 --- a/lib/src/services/asgardeo-navigator.service.ts +++ b/lib/src/services/asgardeo-navigator.service.ts @@ -64,4 +64,13 @@ export class AsgardeoNavigatorService { return window.location.href.split("?")[0]; } } + + getCurrentUrl(): string { + if (this.router) { + return this.router.url; + } else { + return window.location.href; + } + + } } From 95ea6be8618ac56666e04e8e26c0ab865ff6e507 Mon Sep 17 00:00:00 2001 From: Theviyanthan Krishnamohan Date: Thu, 7 Jul 2022 10:11:51 +0530 Subject: [PATCH 2/2] Update lib/src/components/asgardeo-sign-in-redirect.component.ts --- lib/src/components/asgardeo-sign-in-redirect.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/components/asgardeo-sign-in-redirect.component.ts b/lib/src/components/asgardeo-sign-in-redirect.component.ts index 422dbf0..edf8669 100644 --- a/lib/src/components/asgardeo-sign-in-redirect.component.ts +++ b/lib/src/components/asgardeo-sign-in-redirect.component.ts @@ -21,7 +21,7 @@ import { Component, OnInit } from "@angular/core"; import { Hooks } from "../models/asgardeo-spa.models"; import { AsgardeoAuthService } from "../services/asgardeo-auth.service"; import { AsgardeoNavigatorService } from "../services/asgardeo-navigator.service"; -import {SPAUtils} from "@asgardeo/auth-spa"; +import { SPAUtils } from "@asgardeo/auth-spa"; @Component({ selector: "lib-asgardeo-sign-in-redirect",