mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 13:57:14 -04:00
Merge pull request #1500 from dkanada/password
Add optional password field on user creation
This commit is contained in:
commit
6cf9204219
@ -214,6 +214,9 @@ namespace MediaBrowser.Api
|
|||||||
{
|
{
|
||||||
[ApiMember(Name = "Name", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")]
|
[ApiMember(Name = "Name", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[ApiMember(Name = "Password", IsRequired = false, DataType = "string", ParameterType = "body", Verb = "POST")]
|
||||||
|
public string Password { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("/Users/ForgotPassword", "POST", Summary = "Initiates the forgot password process for a local user")]
|
[Route("/Users/ForgotPassword", "POST", Summary = "Initiates the forgot password process for a local user")]
|
||||||
@ -406,7 +409,6 @@ namespace MediaBrowser.Api
|
|||||||
PasswordSha1 = request.Password,
|
PasswordSha1 = request.Password,
|
||||||
RemoteEndPoint = Request.RemoteIp,
|
RemoteEndPoint = Request.RemoteIp,
|
||||||
Username = request.Username
|
Username = request.Username
|
||||||
|
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
return ToOptimizedResult(result);
|
return ToOptimizedResult(result);
|
||||||
@ -501,27 +503,21 @@ namespace MediaBrowser.Api
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Posts the specified request.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="request">The request.</param>
|
|
||||||
/// <returns>System.Object.</returns>
|
|
||||||
public async Task<object> Post(CreateUserByName request)
|
public async Task<object> Post(CreateUserByName request)
|
||||||
{
|
{
|
||||||
var dtoUser = request;
|
var newUser = await _userManager.CreateUser(request.Name).ConfigureAwait(false);
|
||||||
|
|
||||||
var newUser = await _userManager.CreateUser(dtoUser.Name).ConfigureAwait(false);
|
// no need to authenticate password for new user
|
||||||
|
if (request.Password != null)
|
||||||
|
{
|
||||||
|
await _userManager.ChangePassword(newUser, request.Password).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
var result = _userManager.GetUserDto(newUser, Request.RemoteIp);
|
var result = _userManager.GetUserDto(newUser, Request.RemoteIp);
|
||||||
|
|
||||||
return ToOptimizedResult(result);
|
return ToOptimizedResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Posts the specified request.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="request">The request.</param>
|
|
||||||
/// <returns>System.Object.</returns>
|
|
||||||
public async Task<object> Post(ForgotPassword request)
|
public async Task<object> Post(ForgotPassword request)
|
||||||
{
|
{
|
||||||
var isLocal = Request.IsLocal || _networkManager.IsInLocalNetwork(Request.RemoteIp);
|
var isLocal = Request.IsLocal || _networkManager.IsInLocalNetwork(Request.RemoteIp);
|
||||||
|
Loading…
Reference in New Issue
Block a user