From 550854ae957371cbff739f47ee9d9c8b9f403991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Tue, 7 Nov 2023 00:05:53 +0100 Subject: [PATCH] Back to path after login --- Frontend/src/app/auth/auth.guard.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Frontend/src/app/auth/auth.guard.ts b/Frontend/src/app/auth/auth.guard.ts index 84473bb..5062588 100644 --- a/Frontend/src/app/auth/auth.guard.ts +++ b/Frontend/src/app/auth/auth.guard.ts @@ -7,14 +7,20 @@ import { AuthService } from './auth.service'; providedIn: 'root' }) export class AuthGuard { + loginUrl: string | null = null; constructor( private auth$: AuthService, - private router$: Router + private router$: Router, ) {} canActivate(): Observable | Promise | boolean | UrlTree { if (this.auth$.user && this.auth$.user.googleCredentials) { + if (this.loginUrl) { + this.router$.navigate([this.loginUrl]); + this.loginUrl = null; + } return true; } else { + this.loginUrl = window.location.pathname; this.router$.navigate(['']); return false; }