|
|
@ -15,51 +15,57 @@ using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
|
|
namespace PlexRequests.UI
|
|
|
|
namespace PlexRequests.UI
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class UserManagementModule : BaseModule
|
|
|
|
public class UserManagementModule : BaseModule
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public UserManagementModule () : base("usermanagement")
|
|
|
|
public UserManagementModule() : base("usermanagement")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.RequiresClaims (UserClaims.Admin);
|
|
|
|
this.RequiresClaims(UserClaims.Admin);
|
|
|
|
Get["/"] = x => Load();
|
|
|
|
Get["/"] = x => Load();
|
|
|
|
|
|
|
|
|
|
|
|
Get ["/users"] = x => LoadUsers ();
|
|
|
|
Get["/users"] = x => LoadUsers();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Negotiator Load()
|
|
|
|
private Negotiator Load()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return View ["Index"];
|
|
|
|
return View["Index"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Response LoadUsers()
|
|
|
|
private Response LoadUsers()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var users = UserMapper.GetUsers ();
|
|
|
|
var users = UserMapper.GetUsers();
|
|
|
|
var model = new List<UserManagementUsersViewModel>();
|
|
|
|
var model = new List<UserManagementUsersViewModel>();
|
|
|
|
foreach (var user in users) {
|
|
|
|
foreach (var user in users)
|
|
|
|
model.Add (new UserManagementUsersViewModel {
|
|
|
|
{
|
|
|
|
//Claims = ByteConverterHelper.ReturnObject<string[]>(user.Claims),
|
|
|
|
model.Add(new UserManagementUsersViewModel
|
|
|
|
Claims = "test",
|
|
|
|
{
|
|
|
|
Id = user.Id,
|
|
|
|
//Claims = ByteConverterHelper.ReturnObject<string[]>(user.Claims),
|
|
|
|
Username = user.UserName,
|
|
|
|
Claims = "test",
|
|
|
|
//Type = UserType.LocalUser
|
|
|
|
Id = user.Id,
|
|
|
|
});
|
|
|
|
Username = user.UserName,
|
|
|
|
}
|
|
|
|
//Type = UserType.LocalUser
|
|
|
|
return Response.AsJson (users);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Response.AsJson(users);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Response CreateUser(string username, string password, string claims)
|
|
|
|
private Response CreateUser(string username, string password, string claims)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (string.IsNullOrWhiteSpace (username) || string.IsNullOrWhiteSpace (password)) {
|
|
|
|
if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))
|
|
|
|
return Response.AsJson (new JsonResponseModel {
|
|
|
|
{
|
|
|
|
Result = true,
|
|
|
|
return Response.AsJson(new JsonResponseModel
|
|
|
|
Message = "Please enter in a valid Username and Password"
|
|
|
|
{
|
|
|
|
});
|
|
|
|
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});
|
|
|
|
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"});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|