pull/226/head
tidusjar 9 years ago
parent 437a28b108
commit f0b63e0fdd

@ -120,7 +120,7 @@ namespace PlexRequests.UI.Modules
{
dbMovies = t.Result.ToList();
if (settings.UsersCanViewOnlyOwnRequests && !isAdmin)
if (settings.UsersCanViewOnlyOwnRequests && !IsAdmin)
{
dbMovies = dbMovies.Where(x => x.UserHasRequested(Username)).ToList();
}
@ -167,10 +167,10 @@ namespace PlexRequests.UI.Modules
Approved = movie.Available || movie.Approved,
Title = movie.Title,
Overview = movie.Overview,
RequestedUsers = isAdmin ? movie.AllUsers.ToArray() : new string[] { },
RequestedUsers = IsAdmin ? movie.AllUsers.ToArray() : new string[] { },
ReleaseYear = movie.ReleaseDate.Year.ToString(),
Available = movie.Available,
Admin = isAdmin,
Admin = IsAdmin,
Issues = movie.Issues.ToString().CamelCaseToWords(),
OtherMessage = movie.OtherMessage,
AdminNotes = movie.AdminNote,
@ -268,7 +268,7 @@ namespace PlexRequests.UI.Modules
{
var settings = PrSettings.GetSettings();
var dbAlbum = Service.GetAll().Where(x => x.Type == RequestType.Album);
if (settings.UsersCanViewOnlyOwnRequests && !isAdmin)
if (settings.UsersCanViewOnlyOwnRequests && !IsAdmin)
{
dbAlbum = dbAlbum.Where(x => x.UserHasRequested(Username));
}

@ -15,51 +15,57 @@ using System.Collections.Generic;
namespace PlexRequests.UI
{
public class UserManagementModule : BaseModule
{
public UserManagementModule () : base("usermanagement")
{
this.RequiresClaims (UserClaims.Admin);
Get["/"] = x => Load();
public class UserManagementModule : BaseModule
{
public UserManagementModule() : base("usermanagement")
{
this.RequiresClaims(UserClaims.Admin);
Get["/"] = x => Load();
Get ["/users"] = x => LoadUsers ();
}
Get["/users"] = x => LoadUsers();
}
private Negotiator Load()
{
return View ["Index"];
}
private Negotiator Load()
{
return View["Index"];
}
private 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);
}
private 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);
}
private Response CreateUser(string username, string password, string claims)
{
if (string.IsNullOrWhiteSpace (username) || string.IsNullOrWhiteSpace (password)) {
return Response.AsJson (new JsonResponseModel {
Result = true,
Message = "Please enter in a valid Username and Password"
});
}
var user = UserMapper.CreateUser (username, password, new string[]{ claims });
if(user.HasValue){
return Response.AsJson(new JsonResponseModel{ Result = true});
}
private Response CreateUser(string username, string password, string claims)
{
if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))
{
return Response.AsJson(new JsonResponseModel
{
Result = true,
Message = "Please enter in a valid Username and Password"
});
}
var user = UserMapper.CreateUser(username, password, new string[] {claims});
if (user.HasValue)
{
return Response.AsJson(new JsonResponseModel {Result = true});
}
return Response.AsJson(new JsonResponseModel{ Result = false, Message = "Could not save user"});
}
return Response.AsJson(new JsonResponseModel {Result = false, Message = "Could not save user"});
}
}
}

Loading…
Cancel
Save