Skip to content

Commit

Permalink
Merge pull request #1886 from DSD-DBS/dont-redirect-to-auth
Browse files Browse the repository at this point in the history
fix: Don't loop-redirect to `/auth` or `/logout`
  • Loading branch information
MoritzWeber0 authored Oct 8, 2024
2 parents 69159ef + e5d9bca commit 102261e
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ export class AuthRedirectComponent implements OnInit {

ngOnInit(): void {
this.route.queryParams.subscribe((params) => {
const redirectTo = sessionStorage.getItem(params.state);
// After removal of the query params there is nothing to do.
if (Object.keys(params).length === 0) return;
this.router.navigate([], { queryParams: {} });

const redirectTo = sessionStorage.getItem(params.state);
if (params.error) {
this.authService.redirectURL = redirectTo ?? undefined;
const redirect_url =
Expand Down Expand Up @@ -85,7 +88,15 @@ export class AuthRedirectComponent implements OnInit {
localStorage.setItem(this.authService.LOGGED_IN_KEY, 'true');
this.userService.updateOwnUser();
this.feedbackService.triggerFeedbackPrompt();
this.router.navigateByUrl(redirectTo);

if (
redirectTo.startsWith('/auth') ||
redirectTo.startsWith('/logout')
) {
this.router.navigateByUrl('/');
} else {
this.router.navigateByUrl(redirectTo);
}
},
error: () => {
this.authService.redirectURL = redirectTo ?? undefined;
Expand Down

0 comments on commit 102261e

Please sign in to comment.