Merged battery repo

This commit is contained in:
2023-11-25 11:09:01 -05:00
parent b41834fc50
commit 9c779da4d2
65 changed files with 56 additions and 80 deletions

View File

@@ -0,0 +1,17 @@
import {CanActivate, Router} from '@angular/router';
import {Injectable} from '@angular/core';
import {Observable} from 'rxjs';
import {filter, map, tap} from 'rxjs/operators';
import {AuthService} from '../services/auth.service';
@Injectable({
providedIn: 'root'
})
export class GuestGuard implements CanActivate {
constructor(private auth: AuthService, private router: Router) {}
canActivate(): Observable<boolean> {
return this.auth.user.pipe(filter((user: any) => user != null), map(user => user && user.isAnonymous), tap(auth => auth ? this.router.navigate(['/']) : null));
}
}