Skip to content

Commit

Permalink
[SG-656] Send a captcha bypass token back from the register endpoint (#…
Browse files Browse the repository at this point in the history
…2278)

* Send a captcha bypass token back from the register endpoint

* [review] Use existing user

* [review] Introduce ICaptcheProtectedResponseModel
  • Loading branch information
addisonbeck committed Sep 15, 2022
1 parent 22c37bd commit 897658a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/Identity/Controllers/AccountsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,22 @@ namespace Bit.Identity.Controllers
[ExceptionHandlerFilter]
public class AccountsController : Controller
{

private readonly ILogger<AccountsController> _logger;
private readonly IUserRepository _userRepository;
private readonly IUserService _userService;
private readonly ICaptchaValidationService _captchaValidationService;

public AccountsController(
ILogger<AccountsController> logger,
IUserRepository userRepository,
IUserService userService)
IUserService userService,
ICaptchaValidationService captchaValidationService)
{
_logger = logger;
_userRepository = userRepository;
_userService = userService;
_captchaValidationService = captchaValidationService;
}

// Moved from API, If you modify this endpoint, please update API as well.
Expand Down
4 changes: 4 additions & 0 deletions src/Identity/Models/ICaptchaProtectedResponseModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public interface ICaptchaProtectedResponseModel
{
public string CaptchaBypassToken { get; set; }
}
14 changes: 14 additions & 0 deletions src/Identity/Models/RegisterResponseModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Bit.Core.Models.Api;

namespace Bit.Identity.Models;

public class RegisterResponseModel : ResponseModel, ICaptchaProtectedResponseModel
{
public RegisterResponseModel(string captchaBypassToken)
: base("register")
{
CaptchaBypassToken = captchaBypassToken;
}

public string CaptchaBypassToken { get; set; }
}
6 changes: 4 additions & 2 deletions test/Identity.Test/Controllers/AccountsControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,23 @@ namespace Bit.Identity.Test.Controllers
{
public class AccountsControllerTests : IDisposable
{

private readonly AccountsController _sut;
private readonly ILogger<AccountsController> _logger;
private readonly IUserRepository _userRepository;
private readonly IUserService _userService;
private readonly ICaptchaValidationService _captchaValidationService;

public AccountsControllerTests()
{
_logger = Substitute.For<ILogger<AccountsController>>();
_userRepository = Substitute.For<IUserRepository>();
_userService = Substitute.For<IUserService>();
_captchaValidationService = Substitute.For<ICaptchaValidationService>();
_sut = new AccountsController(
_logger,
_userRepository,
_userService
_userService,
_captchaValidationService
);
}

Expand Down

0 comments on commit 897658a

Please sign in to comment.