mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 23:52:50 -05:00
Update API endpoint to use RegisterResponseModel (#2282)
This commit is contained in:
@ -35,6 +35,7 @@ public class AccountsController : Controller
|
||||
private readonly IUserService _userService;
|
||||
private readonly ISendRepository _sendRepository;
|
||||
private readonly ISendService _sendService;
|
||||
private readonly ICaptchaValidationService _captchaValidationService;
|
||||
|
||||
public AccountsController(
|
||||
GlobalSettings globalSettings,
|
||||
@ -47,7 +48,8 @@ public class AccountsController : Controller
|
||||
IUserRepository userRepository,
|
||||
IUserService userService,
|
||||
ISendRepository sendRepository,
|
||||
ISendService sendService)
|
||||
ISendService sendService,
|
||||
ICaptchaValidationService captchaValidationService)
|
||||
{
|
||||
_cipherRepository = cipherRepository;
|
||||
_folderRepository = folderRepository;
|
||||
@ -60,11 +62,13 @@ public class AccountsController : Controller
|
||||
_userService = userService;
|
||||
_sendRepository = sendRepository;
|
||||
_sendService = sendService;
|
||||
_captchaValidationService = captchaValidationService;
|
||||
}
|
||||
|
||||
#region DEPRECATED (Moved to Identity Service)
|
||||
|
||||
[Obsolete("2022-01-12 Moved to Identity, left for backwards compatability with older clients")]
|
||||
// This method is still used by self hosted intalls
|
||||
[Obsolete("2022-01-12 Moved to Identity, left for backwards compatability with older clients.")]
|
||||
[HttpPost("prelogin")]
|
||||
[AllowAnonymous]
|
||||
public async Task<PreloginResponseModel> PostPrelogin([FromBody] PreloginRequestModel model)
|
||||
@ -81,17 +85,20 @@ public class AccountsController : Controller
|
||||
return new PreloginResponseModel(kdfInformation);
|
||||
}
|
||||
|
||||
[Obsolete("2022-01-12 Moved to Identity, left for backwards compatability with older clients")]
|
||||
// This method is still used by self hosted intalls
|
||||
[Obsolete("2022-01-12 Moved to Identity, left for backwards compatability with older clients.")]
|
||||
[HttpPost("register")]
|
||||
[AllowAnonymous]
|
||||
[CaptchaProtected]
|
||||
public async Task PostRegister([FromBody] RegisterRequestModel model)
|
||||
public async Task<RegisterResponseModel> PostRegister([FromBody] RegisterRequestModel model)
|
||||
{
|
||||
var result = await _userService.RegisterUserAsync(model.ToUser(), model.MasterPasswordHash,
|
||||
var user = model.ToUser();
|
||||
var result = await _userService.RegisterUserAsync(user, model.MasterPasswordHash,
|
||||
model.Token, model.OrganizationUserId);
|
||||
if (result.Succeeded)
|
||||
{
|
||||
return;
|
||||
var captchaBypassToken = _captchaValidationService.GenerateCaptchaBypassToken(user);
|
||||
return new RegisterResponseModel(captchaBypassToken);
|
||||
}
|
||||
|
||||
foreach (var error in result.Errors.Where(e => e.Code != "DuplicateUserName"))
|
||||
|
Reference in New Issue
Block a user