mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-10-11 18:47:13 +00:00
Refactor permissions check code
Directly check permissions and no subscription (uisettings is always initialized on frontend startup) update permission directive to accept single string add explicit management permission name
This commit is contained in:
1 parent
4603813896
commit
59e359ff98
25 files changed
+74
-125
No files matched your search
@@ -11,7 +11,7 @@ import {
|
||||
} from '@angular/core'
|
||||
import { Meta } from '@angular/platform-browser'
|
||||
import { CookieService } from 'ngx-cookie-service'
|
||||
import { first, Observable, of, tap } from 'rxjs'
|
||||
import { first, Observable, tap } from 'rxjs'
|
||||
import {
|
||||
BRIGHTNESS,
|
||||
estimateBrightnessForColor,
|
||||
@@ -45,7 +45,7 @@ export class SettingsService {
|
||||
protected baseUrl: string = environment.apiBaseUrl + 'ui_settings/'
|
||||
|
||||
private settings: Object = {}
|
||||
private _permissions: string[]
|
||||
private permissions: string[]
|
||||
|
||||
public displayName: string
|
||||
|
||||
@@ -75,7 +75,7 @@ export class SettingsService {
|
||||
if (this.settings['language']?.length)
|
||||
this.setLanguage(this.settings['language'])
|
||||
this.displayName = uisettings.display_name.trim()
|
||||
this._permissions = uisettings.permissions
|
||||
this.permissions = uisettings.permissions
|
||||
})
|
||||
)
|
||||
}
|
||||
@@ -458,7 +458,7 @@ export class SettingsService {
|
||||
)
|
||||
}
|
||||
|
||||
public permissions(): Observable<string[]> {
|
||||
return of(this._permissions)
|
||||
currentUserCan(permission: string): boolean {
|
||||
return this.permissions.includes(permission)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user