mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 21:33:15 -07:00
More work on the user management
This commit is contained in:
parent
d44612217a
commit
15fae26397
8 changed files with 75 additions and 21 deletions
|
@ -50,7 +50,7 @@ namespace PlexRequests.UI.Modules
|
|||
ISettingsService<SonarrSettings> sonarrSettings, ISickRageApi srApi, ISettingsService<SickRageSettings> srSettings,
|
||||
ISettingsService<HeadphonesSettings> hpSettings, IHeadphonesApi hpApi) : base("approval")
|
||||
{
|
||||
this.RequiresAuthentication();
|
||||
this.RequiresClaims(UserClaims.Admin, UserClaims.PowerUser);
|
||||
|
||||
Service = service;
|
||||
CpService = cpService;
|
||||
|
@ -88,10 +88,7 @@ namespace PlexRequests.UI.Modules
|
|||
private Response Approve(int requestId, string qualityId)
|
||||
{
|
||||
Log.Info("approving request {0}", requestId);
|
||||
if (!Context.CurrentUser.IsAuthenticated())
|
||||
{
|
||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = "You are not an Admin, so you cannot approve any requests." });
|
||||
}
|
||||
|
||||
// Get the request from the DB
|
||||
var request = Service.Get(requestId);
|
||||
|
||||
|
@ -258,10 +255,6 @@ namespace PlexRequests.UI.Modules
|
|||
|
||||
private Response ApproveAllMovies()
|
||||
{
|
||||
if (!Context.CurrentUser.IsAuthenticated())
|
||||
{
|
||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = "You are not an Admin, so you cannot approve any requests." });
|
||||
}
|
||||
|
||||
var requests = Service.GetAll().Where(x => x.CanApprove && x.Type == RequestType.Movie);
|
||||
var requestedModels = requests as RequestedModel[] ?? requests.ToArray();
|
||||
|
@ -312,11 +305,6 @@ namespace PlexRequests.UI.Modules
|
|||
/// <returns></returns>
|
||||
private Response ApproveAll()
|
||||
{
|
||||
if (!Context.CurrentUser.IsAuthenticated())
|
||||
{
|
||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = "You are not an Admin, so you cannot approve any requests." });
|
||||
}
|
||||
|
||||
var requests = Service.GetAll().Where(x => x.CanApprove);
|
||||
var requestedModels = requests as RequestedModel[] ?? requests.ToArray();
|
||||
if (!requestedModels.Any())
|
||||
|
|
|
@ -500,7 +500,7 @@ namespace PlexRequests.UI.Modules
|
|||
RequestService.AddRequest(model);
|
||||
|
||||
|
||||
if (ShouldSendNotification) {
|
||||
if (ShouldSendNotification()) {
|
||||
var notificationModel = new NotificationModel {
|
||||
Title = model.Title,
|
||||
User = Username,
|
||||
|
@ -525,7 +525,7 @@ namespace PlexRequests.UI.Modules
|
|||
Log.Info("Adding movie to database (No approval required)");
|
||||
RequestService.AddRequest(model);
|
||||
|
||||
if (ShouldSendNotification) {
|
||||
if (ShouldSendNotification()) {
|
||||
var notificationModel = new NotificationModel {
|
||||
Title = model.Title,
|
||||
User = Username,
|
||||
|
@ -660,7 +660,7 @@ namespace PlexRequests.UI.Modules
|
|||
Log.Debug("Adding tv to database requests (No approval required & Sonarr)");
|
||||
RequestService.AddRequest(model);
|
||||
|
||||
if (ShouldSendNotification) {
|
||||
if (ShouldSendNotification()) {
|
||||
var notify1 = new NotificationModel {
|
||||
Title = model.Title,
|
||||
User = Username,
|
||||
|
@ -686,7 +686,7 @@ namespace PlexRequests.UI.Modules
|
|||
model.Approved = true;
|
||||
Log.Debug("Adding tv to database requests (No approval required & SickRage)");
|
||||
RequestService.AddRequest(model);
|
||||
if (ShouldSendNotification) {
|
||||
if (ShouldSendNotification()) {
|
||||
var notify2 = new NotificationModel {
|
||||
Title = model.Title,
|
||||
User = Username,
|
||||
|
|
|
@ -10,6 +10,7 @@ using PlexRequests.Core;
|
|||
using PlexRequests.UI.Models;
|
||||
using PlexRequests.UI.Modules;
|
||||
using PlexRequests.Helpers;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace PlexRequests.UI
|
||||
|
@ -32,6 +33,16 @@ namespace PlexRequests.UI
|
|||
public Response LoadUsers()
|
||||
{
|
||||
var users = UserMapper.GetUsers ();
|
||||
var model = new List<UserManagementUsersViewModel>();
|
||||
foreach (var user in users) {
|
||||
model.Add (new UserManagementUsersViewModel {
|
||||
//Claims = ByteConverterHelper.ReturnObject<string[]>(user.Claims),
|
||||
Claims = "test",
|
||||
Id = user.Id,
|
||||
Username = user.UserName,
|
||||
//Type = UserType.LocalUser
|
||||
});
|
||||
}
|
||||
return Response.AsJson (users);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue