Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent redirecting again in the middle of redirect (ORCID#1926) #1927

Closed
Changes from all commits
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
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that we have 2 redirects, one is called by GTM library it self, and the other one is called by sendUserToRedirectURL.

So in reality the sendUserToRedirectURL is only call once, and that is why this boolean check does not work .


return NEVER
}

Expand Down