Navigate to root path after successful login via login/:code route in AuthGuard.

This commit is contained in:
akastijn 2025-11-08 18:06:13 +01:00
parent b7c553acc1
commit 7315ea8455

View File

@ -27,6 +27,9 @@ export class AuthGuard implements CanActivate {
return this.authService.login(code).pipe( return this.authService.login(code).pipe(
switchMap(() => { switchMap(() => {
const result = this.canActivateInternal(route, state); const result = this.canActivateInternal(route, state);
if (route.routeConfig?.path === 'login/:code') {
this.router.navigateByUrl('/', {replaceUrl: true}).then();
}
return isObservable(result) ? result : result instanceof Promise ? from(result) : of(result); return isObservable(result) ? result : result instanceof Promise ? from(result) : of(result);
}), }),
catchError(() => of(this.router.createUrlTree(['/']))) catchError(() => of(this.router.createUrlTree(['/'])))