Skip to content

Commit

Permalink
Prevent redirecting againt in the middle of redirect (ORCID#1926)
Browse files Browse the repository at this point in the history
  • Loading branch information
kadet1090 committed Apr 7, 2023
1 parent b3920b8 commit 8518a89
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/app/guards/authorize.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { GoogleTagManagerService } from '../core/google-tag-manager/google-tag-m
})
export class AuthorizeGuard implements CanActivateChild {
lastRedirectUrl: string
inTheMiddleOfRedirect: boolean = false
constructor(
private _user: UserService,
private _router: Router,
Expand Down Expand Up @@ -67,7 +68,14 @@ export class AuthorizeGuard implements CanActivateChild {
}

sendUserToRedirectURL(oauthSession: RequestInfoForm): Observable<boolean> {
// Prevent double redirection caused by races using simple semaphore like construct
if (this.inTheMiddleOfRedirect) {
return;
}

this.window.location.href = oauthSession.redirectUrl
this.inTheMiddleOfRedirect = true;

return NEVER
}

Expand Down

0 comments on commit 8518a89

Please sign in to comment.