mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-23 14:35:24 -07:00
Improve performance and clean up code
This commit is contained in:
parent
ef70eeeae3
commit
8ec78ad6dc
3 changed files with 13 additions and 15 deletions
|
@ -82,14 +82,17 @@ namespace Ombi.Core.Engine
|
||||||
|
|
||||||
// Admins can always manage requests
|
// Admins can always manage requests
|
||||||
var isAdmin = await IsInRole(OmbiRoles.PowerUser) || await IsInRole(OmbiRoles.Admin);
|
var isAdmin = await IsInRole(OmbiRoles.PowerUser) || await IsInRole(OmbiRoles.Admin);
|
||||||
if (isAdmin)
|
if (isAdmin) {
|
||||||
return new RequestEngineResult { Result = true };
|
return new RequestEngineResult { Result = true };
|
||||||
|
}
|
||||||
// Users with 'ManageOwnRequests' can only manage their own requests
|
// Users with 'ManageOwnRequests' can only manage their own requests
|
||||||
var isRequestedBySameUser = ( await GetUser() ).Equals(request.RequestedUser);
|
|
||||||
var canManageOwnRequests = await IsInRole(OmbiRoles.ManageOwnRequests);
|
var canManageOwnRequests = await IsInRole(OmbiRoles.ManageOwnRequests);
|
||||||
if(canManageOwnRequests && isRequestedBySameUser)
|
if (canManageOwnRequests) {
|
||||||
return new RequestEngineResult { Result = true };
|
var isRequestedBySameUser = ( await GetUser() ).Equals(request.RequestedUser);
|
||||||
|
if (!isRequestedBySameUser) {
|
||||||
|
return new RequestEngineResult { Result = true };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return new RequestEngineResult
|
return new RequestEngineResult
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,6 @@ import { RequestServiceV2 } from "../../../services/requestV2.service";
|
||||||
import { AuthService } from "../../../auth/auth.service";
|
import { AuthService } from "../../../auth/auth.service";
|
||||||
import { StorageService } from "../../../shared/storage/storage-service";
|
import { StorageService } from "../../../shared/storage/storage-service";
|
||||||
import { RequestFilterType } from "../../models/RequestFilterType";
|
import { RequestFilterType } from "../../models/RequestFilterType";
|
||||||
import { IdentityService } from "../../../services";
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: "./albums-grid.component.html",
|
templateUrl: "./albums-grid.component.html",
|
||||||
|
@ -43,11 +42,9 @@ export class AlbumsGridComponent implements OnInit, AfterViewInit {
|
||||||
@ViewChild(MatSort) sort: MatSort;
|
@ViewChild(MatSort) sort: MatSort;
|
||||||
|
|
||||||
constructor(private requestService: RequestServiceV2, private ref: ChangeDetectorRef,
|
constructor(private requestService: RequestServiceV2, private ref: ChangeDetectorRef,
|
||||||
private auth: AuthService, private storageService: StorageService, private identity: IdentityService) {
|
private auth: AuthService, private storageService: StorageService) {
|
||||||
|
|
||||||
identity.getUser().subscribe(u => {
|
this.userName = auth.claims().name;
|
||||||
this.userName = u.userName;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnInit() {
|
public ngOnInit() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { AfterViewInit, ChangeDetectorRef, Component, EventEmitter, OnInit, Output, ViewChild } from "@angular/core";
|
import { AfterViewInit, ChangeDetectorRef, Component, EventEmitter, OnInit, Output, ViewChild } from "@angular/core";
|
||||||
import { IMovieRequests, IRequestEngineResult, IRequestsViewModel } from "../../../interfaces";
|
import { IMovieRequests, IRequestEngineResult, IRequestsViewModel } from "../../../interfaces";
|
||||||
import { IdentityService, NotificationService, RequestService } from "../../../services";
|
import { NotificationService, RequestService } from "../../../services";
|
||||||
import { Observable, forkJoin, merge, of as observableOf } from 'rxjs';
|
import { Observable, forkJoin, merge, of as observableOf } from 'rxjs';
|
||||||
import { catchError, map, startWith, switchMap } from 'rxjs/operators';
|
import { catchError, map, startWith, switchMap } from 'rxjs/operators';
|
||||||
|
|
||||||
|
@ -49,11 +49,9 @@ export class MoviesGridComponent implements OnInit, AfterViewInit {
|
||||||
constructor(private requestService: RequestServiceV2, private ref: ChangeDetectorRef,
|
constructor(private requestService: RequestServiceV2, private ref: ChangeDetectorRef,
|
||||||
private auth: AuthService, private storageService: StorageService,
|
private auth: AuthService, private storageService: StorageService,
|
||||||
private requestServiceV1: RequestService, private notification: NotificationService,
|
private requestServiceV1: RequestService, private notification: NotificationService,
|
||||||
private translateService: TranslateService, private identity: IdentityService) {
|
private translateService: TranslateService) {
|
||||||
|
|
||||||
identity.getUser().subscribe(u => {
|
this.userName = auth.claims().name;
|
||||||
this.userName = u.userName;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnInit() {
|
public ngOnInit() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue