From 6c269192e00d5a9c8a8d86f198340f9684ccdd98 Mon Sep 17 00:00:00 2001 From: leomendoza123 Date: Fri, 31 Mar 2023 10:10:53 -0600 Subject: [PATCH] Fix/double redirect issue (#1924) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * double-redirect-issue * protect double redirect * Take one * remove logs * remove logs * Remove test data * fix logic * 🤖 GITHUB ACTIONS * Revert ublock fix * Rever unrequired changes * Add logs * 🤖 GITHUB ACTIONS * Final fix --- src/app/guards/authorize.guard.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/app/guards/authorize.guard.ts b/src/app/guards/authorize.guard.ts index 6c6fd81105..83feb793ba 100644 --- a/src/app/guards/authorize.guard.ts +++ b/src/app/guards/authorize.guard.ts @@ -6,7 +6,7 @@ import { RouterStateSnapshot, UrlTree, } from '@angular/router' -import { forkJoin, NEVER, Observable, of, throwError } from 'rxjs' +import { forkJoin, NEVER, Observable, of, throwError, timer } from 'rxjs' import { catchError, map, switchMap, take, tap, timeout } from 'rxjs/operators' import { PlatformInfoService } from '../cdk/platform-info' @@ -67,13 +67,7 @@ export class AuthorizeGuard implements CanActivateChild { } sendUserToRedirectURL(oauthSession: RequestInfoForm): Observable { - console.log('sendUserToRedirectURL ', oauthSession) - - // if (this.lastRedirectUrl !== oauthSession.redirectUrl) { - // this.lastRedirectUrl = oauthSession.redirectUrl this.window.location.href = oauthSession.redirectUrl - // } - return NEVER } @@ -104,9 +98,11 @@ export class AuthorizeGuard implements CanActivateChild { ) return this.sendUserToRedirectURL(request) }), - switchMap(() => { - return NEVER - }) + // If and Add blocker like Ublock is enable the GTM `redirectURL` will never be called + // This add blockers will also not trigger the `catchError` above, since GTM will not throw an error + // So this timeout will redirect the user to the redirectURL after 4 seconds of waiting for the GTM redirect + switchMap(() => timer(4000)), + switchMap(() => this.sendUserToRedirectURL(request)) ) }