mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-09 00:05:21 +01: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:
parent
4603813896
commit
59e359ff98
25 changed files with 74 additions and 125 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue