Restrict access to Bookdrop and Metadata Manager pages for unauthorized users (#1363)
This commit is contained in:
@@ -3,6 +3,7 @@ import {BehaviorSubject, Subscription} from 'rxjs';
|
||||
import {map, filter, take} from 'rxjs/operators';
|
||||
import {BookdropFileApiService} from './bookdrop-file-api.service';
|
||||
import {AuthService} from '../../../shared/service/auth.service';
|
||||
import {UserService} from '../../settings/user-management/user.service';
|
||||
|
||||
export interface BookdropFileNotification {
|
||||
pendingCount: number;
|
||||
@@ -28,11 +29,22 @@ export class BookdropFileService implements OnDestroy {
|
||||
private apiService = inject(BookdropFileApiService);
|
||||
private authService = inject(AuthService);
|
||||
private subscriptions = new Subscription();
|
||||
private userService = inject(UserService);
|
||||
|
||||
constructor() {
|
||||
this.authService.token$
|
||||
.pipe(filter(t => !!t), take(1))
|
||||
.subscribe(() => this.refresh());
|
||||
this.userService.userState$
|
||||
.pipe(
|
||||
filter(state => state.loaded && !!state.user),
|
||||
take(1)
|
||||
)
|
||||
.subscribe(state => {
|
||||
const user = state.user!;
|
||||
if (user.permissions.admin || user.permissions.canManipulateLibrary) {
|
||||
this.authService.token$
|
||||
.pipe(filter(t => !!t), take(1))
|
||||
.subscribe(() => this.refresh());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
handleIncomingFile(summary: BookdropFileNotification): void {
|
||||
|
||||
Reference in New Issue
Block a user