Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Fix the login loop when signing in after configuring angular router. #123

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/src/components/asgardeo-sign-in-redirect.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
thivi marked this conversation as resolved.
Show resolved Hide resolved

@Component({
selector: "lib-asgardeo-sign-in-redirect",
Expand All @@ -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();
}
}
}
9 changes: 9 additions & 0 deletions lib/src/services/asgardeo-navigator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
}