1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-23 12:25:16 +01:00

feat(NewDeviceVerification): adding method to request a new email OTP for Device Verification.

This commit is contained in:
Ike Kottlowski 2024-11-22 14:48:25 -08:00
parent 3904a38394
commit b9e0114931
No known key found for this signature in database
GPG Key ID: C86308E3DCA6D76F

View File

@ -961,6 +961,20 @@ public class AccountsController : Controller
}
}
[RequireFeature("new-device-verification")]
[AllowAnonymous]
[HttpPost("request-device-verification-otp")]
public async Task SendDeviceVerificationEmailOTP(SecretVerificationRequestModel model){
var user = await _userService.GetUserByPrincipalAsync(User) ?? throw new UnauthorizedAccessException();
if (!await _userService.VerifySecretAsync(user, model.Secret))
{
await Task.Delay(2000);
throw new BadRequestException(string.Empty, "User verification failed.");
}
await _userService.SendOTPAsync(user);
}
private async Task<IEnumerable<Guid>> GetOrganizationIdsManagingUserAsync(Guid userId)
{
var organizationManagingUser = await _userService.GetOrganizationsManagingUserAsync(userId);