Verify user invite token (#14491)
* Added functionality to verify user invite tokens and create the initial password * Add response types * Fail ValidateCredentialsAsync when user is not approved * Enable user as part of initial password creating using validation token * Adds documentation to badrequest and changed nocontent to ok, to align with other APIs * Fixed tests and added a new one --------- Co-authored-by: nikolajlauridsen <nikolajlauridsen@protonmail.ch>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using Asp.Versioning;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Umbraco.Cms.Api.Management.ViewModels.User;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Core.Services.OperationStatus;
|
||||
|
||||
namespace Umbraco.Cms.Api.Management.Controllers.User;
|
||||
|
||||
[ApiVersion("1.0")]
|
||||
public class VerifyInviteUserController : UserControllerBase
|
||||
{
|
||||
private readonly IUserService _userService;
|
||||
|
||||
public VerifyInviteUserController(IUserService userService) => _userService = userService;
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost("invite/verify")]
|
||||
[MapToApiVersion("1.0")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<IActionResult> Invite(VerifyInviteUserRequestModel model)
|
||||
{
|
||||
Attempt<UserOperationStatus> result = await _userService.VerifyInviteAsync(model.UserId, model.Token);
|
||||
|
||||
return result.Success
|
||||
? Ok()
|
||||
: UserOperationStatusResult(result.Result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user