mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
retain user / group permissions the UI doesnt use
This commit is contained in:
parent
10f36870e6
commit
b6f1ced455
@ -1,13 +1,31 @@
|
|||||||
import { HttpClient } from '@angular/common/http'
|
import { HttpClient } from '@angular/common/http'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
|
import { Observable, switchMap } from 'rxjs'
|
||||||
import { PaperlessGroup } from 'src/app/data/paperless-group'
|
import { PaperlessGroup } from 'src/app/data/paperless-group'
|
||||||
|
import { PermissionsService } from '../permissions.service'
|
||||||
import { AbstractNameFilterService } from './abstract-name-filter-service'
|
import { AbstractNameFilterService } from './abstract-name-filter-service'
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class GroupService extends AbstractNameFilterService<PaperlessGroup> {
|
export class GroupService extends AbstractNameFilterService<PaperlessGroup> {
|
||||||
constructor(http: HttpClient) {
|
constructor(http: HttpClient, private permissionService: PermissionsService) {
|
||||||
super(http, 'groups')
|
super(http, 'groups')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update(o: PaperlessGroup): Observable<PaperlessGroup> {
|
||||||
|
return this.getCached(o.id).pipe(
|
||||||
|
switchMap((initialGroup) => {
|
||||||
|
initialGroup.permissions?.forEach((perm) => {
|
||||||
|
const { typeKey, actionKey } =
|
||||||
|
this.permissionService.getPermissionKeys(perm)
|
||||||
|
if (!typeKey || !actionKey) {
|
||||||
|
// dont lose permissions the UI doesnt use
|
||||||
|
o.permissions.push(perm)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return super.update(o)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,31 @@
|
|||||||
import { HttpClient } from '@angular/common/http'
|
import { HttpClient } from '@angular/common/http'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
|
import { Observable, switchMap } from 'rxjs'
|
||||||
import { PaperlessUser } from 'src/app/data/paperless-user'
|
import { PaperlessUser } from 'src/app/data/paperless-user'
|
||||||
|
import { PermissionsService } from '../permissions.service'
|
||||||
import { AbstractNameFilterService } from './abstract-name-filter-service'
|
import { AbstractNameFilterService } from './abstract-name-filter-service'
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class UserService extends AbstractNameFilterService<PaperlessUser> {
|
export class UserService extends AbstractNameFilterService<PaperlessUser> {
|
||||||
constructor(http: HttpClient) {
|
constructor(http: HttpClient, private permissionService: PermissionsService) {
|
||||||
super(http, 'users')
|
super(http, 'users')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update(o: PaperlessUser): Observable<PaperlessUser> {
|
||||||
|
return this.getCached(o.id).pipe(
|
||||||
|
switchMap((initialUser) => {
|
||||||
|
initialUser.user_permissions?.forEach((perm) => {
|
||||||
|
const { typeKey, actionKey } =
|
||||||
|
this.permissionService.getPermissionKeys(perm)
|
||||||
|
if (!typeKey || !actionKey) {
|
||||||
|
// dont lose permissions the UI doesnt use
|
||||||
|
o.user_permissions.push(perm)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return super.update(o)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user