mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-17 22:43:07 +03:00
Change arguments AssertCanUpdateUser to take a user
This commit is contained in:
@@ -274,16 +274,15 @@ public class UserController : BaseJellyfinApiController
|
||||
[FromBody, Required] UpdateUserPassword request)
|
||||
{
|
||||
var requestUserId = userId ?? User.GetUserId();
|
||||
if (!RequestHelpers.AssertCanUpdateUser(_userManager, User, requestUserId, true))
|
||||
{
|
||||
return StatusCode(StatusCodes.Status403Forbidden, "User is not allowed to update the password.");
|
||||
}
|
||||
|
||||
var user = _userManager.GetUserById(requestUserId);
|
||||
|
||||
if (user is null)
|
||||
{
|
||||
return NotFound("User not found");
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if (!RequestHelpers.AssertCanUpdateUser(User, user, true))
|
||||
{
|
||||
return StatusCode(StatusCodes.Status403Forbidden, "User is not allowed to update the password.");
|
||||
}
|
||||
|
||||
if (request.ResetPassword)
|
||||
@@ -386,7 +385,7 @@ public class UserController : BaseJellyfinApiController
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if (!RequestHelpers.AssertCanUpdateUser(_userManager, User, requestUserId, true))
|
||||
if (!RequestHelpers.AssertCanUpdateUser(User, user, true))
|
||||
{
|
||||
return StatusCode(StatusCodes.Status403Forbidden, "User update not allowed.");
|
||||
}
|
||||
@@ -396,7 +395,7 @@ public class UserController : BaseJellyfinApiController
|
||||
await _userManager.RenameUser(user, updateUser.Name).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await _userManager.UpdateConfigurationAsync(user.Id, updateUser.Configuration).ConfigureAwait(false);
|
||||
await _userManager.UpdateConfigurationAsync(requestUserId, updateUser.Configuration).ConfigureAwait(false);
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
@@ -495,7 +494,13 @@ public class UserController : BaseJellyfinApiController
|
||||
[FromBody, Required] UserConfiguration userConfig)
|
||||
{
|
||||
var requestUserId = userId ?? User.GetUserId();
|
||||
if (!RequestHelpers.AssertCanUpdateUser(_userManager, User, requestUserId, true))
|
||||
var user = _userManager.GetUserById(requestUserId);
|
||||
if (user is null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if (!RequestHelpers.AssertCanUpdateUser(User, user, true))
|
||||
{
|
||||
return StatusCode(StatusCodes.Status403Forbidden, "User configuration update not allowed");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user