From eadd831e3f1e0c2082d0a7ee3acfedf7f40fea74 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Mon, 20 Jan 2025 10:09:44 +0100 Subject: [PATCH] feat(auth): use async in canActivate for auth refresh --- src/app/service/auth.service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/service/auth.service.ts b/src/app/service/auth.service.ts index 5181a8f..6c926df 100644 --- a/src/app/service/auth.service.ts +++ b/src/app/service/auth.service.ts @@ -16,8 +16,9 @@ import { environment } from '../../environments/environment'; export class AuthGuard implements CanActivate { constructor(private router: Router) { }; - canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { + async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise { const pb = new PocketBase(environment.POCKETBASE); + await pb.collection('users').authRefresh().catch(() => this.router.navigate([''])); if (pb.authStore.isValid) { return true;