Issues gitea 2.0

This commit is contained in:
2026-01-15 21:35:49 +01:00
parent 09e7ce59a9
commit 447027db2b
4 changed files with 18 additions and 14 deletions

View File

@@ -183,11 +183,8 @@ export class AuthService {
return Promise.resolve();
}
isAdmin(): Observable<boolean> {
return this.getUserRole().pipe(
return this.userRole$.pipe(
map(role => role === 'admin'),
// take(1) ist optional - es beendet die Subscription, nachdem ein Wert geliefert wurde
// Nützlich, wenn du die Methode in einem Template mit dem async pipe verwendest
take(1),
);
}
// Get current user's role from the server with caching
@@ -196,6 +193,9 @@ export class AuthService {
// Cache zurücksetzen, wenn die Caching-Zeit abgelaufen ist oder kein Cache existiert
if (!this.cachedUserRole$ || now - this.lastCacheTime > this.cacheDuration) {
if (!this.getLocalStorageItem('authToken')) {
return of(null);
}
this.lastCacheTime = now;
let headers = new HttpHeaders().set('X-Hide-Loading', 'true').set('Accept-Language', 'en-US');
this.cachedUserRole$ = this.http.get<{ role: UserRole | null }>(`${environment.apiBaseUrl}/bizmatch/auth/me/role`, { headers }).pipe(