mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-12 00:19:48 +00:00
Refactor permissions to use enums, permissions service
This commit is contained in:
@@ -23,6 +23,7 @@ import {
|
||||
SETTINGS,
|
||||
SETTINGS_KEYS,
|
||||
} from '../data/paperless-uisettings'
|
||||
import { PermissionsService } from './permissions.service'
|
||||
import { SavedViewService } from './rest/saved-view.service'
|
||||
import { ToastService } from './toast.service'
|
||||
|
||||
@@ -45,7 +46,6 @@ export class SettingsService {
|
||||
protected baseUrl: string = environment.apiBaseUrl + 'ui_settings/'
|
||||
|
||||
private settings: Object = {}
|
||||
private permissions: string[]
|
||||
|
||||
public displayName: string
|
||||
|
||||
@@ -59,7 +59,8 @@ export class SettingsService {
|
||||
@Inject(LOCALE_ID) private localeId: string,
|
||||
protected http: HttpClient,
|
||||
private toastService: ToastService,
|
||||
private savedViewService: SavedViewService
|
||||
private savedViewService: SavedViewService,
|
||||
private permissionsService: PermissionsService
|
||||
) {
|
||||
this.renderer = rendererFactory.createRenderer(null, null)
|
||||
}
|
||||
@@ -75,7 +76,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.permissionsService.initialize(uisettings.permissions)
|
||||
})
|
||||
)
|
||||
}
|
||||
@@ -457,8 +458,4 @@ export class SettingsService {
|
||||
this.savedViewService.dashboardViews.length == 0
|
||||
)
|
||||
}
|
||||
|
||||
currentUserCan(permission: string): boolean {
|
||||
return this.permissions.includes(permission)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user