mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-10 15:32:37 -07:00
Fixed some issues with the user management work
This commit is contained in:
parent
0bfc8f8393
commit
e39512905a
7 changed files with 138 additions and 12 deletions
|
@ -30,10 +30,13 @@ using System.Linq;
|
|||
using System.Threading;
|
||||
|
||||
using Nancy;
|
||||
|
||||
using Ninject;
|
||||
using PlexRequests.Core;
|
||||
using PlexRequests.Core.SettingModels;
|
||||
using PlexRequests.Helpers;
|
||||
using PlexRequests.Helpers.Permissions;
|
||||
using PlexRequests.Store;
|
||||
using PlexRequests.Store.Repository;
|
||||
using PlexRequests.UI.Helpers;
|
||||
using PlexRequests.UI.Models;
|
||||
|
||||
|
@ -118,6 +121,10 @@ namespace PlexRequests.UI.Modules
|
|||
|
||||
protected IDictionary<string, string> Cookies => Request?.Cookies;
|
||||
|
||||
// This is not ideal, but it's cleaner than having to pass it down through each module.
|
||||
[Inject]
|
||||
protected IUserRepository UserRepository { get; set; }
|
||||
|
||||
protected bool IsAdmin
|
||||
{
|
||||
get
|
||||
|
@ -126,8 +133,14 @@ namespace PlexRequests.UI.Modules
|
|||
{
|
||||
return false;
|
||||
}
|
||||
var claims = Context?.CurrentUser.Claims.ToList();
|
||||
return claims.Contains(UserClaims.Admin) || claims.Contains(UserClaims.PowerUser);
|
||||
|
||||
var user = UserRepository.GetUserByUsername(Context?.CurrentUser?.UserName);
|
||||
|
||||
if (user == null) return false;
|
||||
|
||||
var permissions = (Permissions) user.Permissions;
|
||||
return permissions.HasFlag(Permissions.Administrator);
|
||||
// TODO: Check admin role
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue