mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-05 22:02:15 +00:00
fix(console): remove redundant user api requests, show discovery document loading errors (#6683)
* optimize user observable * fix observable guard * lint * lint --------- Co-authored-by: Elio Bischof <[email protected]>
This commit is contained in:
co-authored by
Elio Bischof
parent
f2d1cd2045
commit
412cd144ef
@@ -1,7 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, tap } from 'rxjs/operators';
|
||||
import { map, Observable, take } from 'rxjs';
|
||||
|
||||
import { GrpcAuthService } from '../services/grpc-auth.service';
|
||||
|
||||
@@ -19,11 +18,13 @@ export class UserGuard {
|
||||
state: RouterStateSnapshot,
|
||||
): Observable<boolean> | Promise<boolean> | boolean {
|
||||
return this.authService.user.pipe(
|
||||
map((user) => user?.id !== route.params['id']),
|
||||
tap((isNotMe) => {
|
||||
if (!isNotMe) {
|
||||
take(1),
|
||||
map((user) => {
|
||||
const isMe = user?.id === route.params['id'];
|
||||
if (isMe) {
|
||||
this.router.navigate(['/users', 'me']);
|
||||
}
|
||||
return !isMe;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user