Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add required attributes to parameters #4711

Merged
merged 1 commit into from Dec 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 6 additions & 16 deletions Jellyfin.Api/Controllers/UserController.cs
Expand Up @@ -267,7 +267,7 @@ public async Task<ActionResult<AuthenticationResult>> AuthenticateWithQuickConne
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> UpdateUserPassword(
[FromRoute, Required] Guid userId,
[FromBody] UpdateUserPassword request)
[FromBody, Required] UpdateUserPassword request)
{
if (!RequestHelpers.AssertCanUpdateUser(_authContext, HttpContext.Request, userId, true))
{
Expand Down Expand Up @@ -325,7 +325,7 @@ public async Task<ActionResult<AuthenticationResult>> AuthenticateWithQuickConne
[ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult UpdateUserEasyPassword(
[FromRoute, Required] Guid userId,
[FromBody] UpdateUserEasyPassword request)
[FromBody, Required] UpdateUserEasyPassword request)
{
if (!RequestHelpers.AssertCanUpdateUser(_authContext, HttpContext.Request, userId, true))
{
Expand Down Expand Up @@ -367,13 +367,8 @@ public async Task<ActionResult<AuthenticationResult>> AuthenticateWithQuickConne
[ProducesResponseType(StatusCodes.Status403Forbidden)]
public async Task<ActionResult> UpdateUser(
[FromRoute, Required] Guid userId,
[FromBody] UserDto updateUser)
[FromBody, Required] UserDto updateUser)
{
if (updateUser == null)
{
return BadRequest();
}

if (!RequestHelpers.AssertCanUpdateUser(_authContext, HttpContext.Request, userId, false))
{
return Forbid("User update not allowed.");
Expand Down Expand Up @@ -407,13 +402,8 @@ public async Task<ActionResult<AuthenticationResult>> AuthenticateWithQuickConne
[ProducesResponseType(StatusCodes.Status403Forbidden)]
public async Task<ActionResult> UpdateUserPolicy(
[FromRoute, Required] Guid userId,
[FromBody] UserPolicy newPolicy)
[FromBody, Required] UserPolicy newPolicy)
{
if (newPolicy == null)
{
return BadRequest();
}

var user = _userManager.GetUserById(userId);

// If removing admin access
Expand Down Expand Up @@ -462,7 +452,7 @@ public async Task<ActionResult<AuthenticationResult>> AuthenticateWithQuickConne
[ProducesResponseType(StatusCodes.Status403Forbidden)]
public async Task<ActionResult> UpdateUserConfiguration(
[FromRoute, Required] Guid userId,
[FromBody] UserConfiguration userConfig)
[FromBody, Required] UserConfiguration userConfig)
{
if (!RequestHelpers.AssertCanUpdateUser(_authContext, HttpContext.Request, userId, false))
{
Expand All @@ -483,7 +473,7 @@ public async Task<ActionResult<AuthenticationResult>> AuthenticateWithQuickConne
[HttpPost("New")]
[Authorize(Policy = Policies.RequiresElevation)]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult<UserDto>> CreateUserByName([FromBody] CreateUserByName request)
public async Task<ActionResult<UserDto>> CreateUserByName([FromBody, Required] CreateUserByName request)
{
var newUser = await _userManager.CreateUserAsync(request.Name).ConfigureAwait(false);

Expand Down