mirror of
https://github.com/bitwarden/server.git
synced 2025-04-06 05:28:15 -05:00
get recovery code api
This commit is contained in:
parent
a0fb1e0907
commit
eea2ae30b4
@ -253,9 +253,17 @@ namespace Bit.Api.Controllers
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("get-recover")]
|
||||||
|
public async Task<TwoFactorRecoverResponseModel> GetRecover([FromBody]TwoFactorRequestModel model)
|
||||||
|
{
|
||||||
|
var user = await CheckPasswordAsync(model.MasterPasswordHash);
|
||||||
|
var response = new TwoFactorRecoverResponseModel(user);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost("recover")]
|
[HttpPost("recover")]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public async Task PostTwoFactorRecover([FromBody]TwoFactorRecoveryRequestModel model)
|
public async Task PostRecover([FromBody]TwoFactorRecoveryRequestModel model)
|
||||||
{
|
{
|
||||||
if(!await _userService.RecoverTwoFactorAsync(model.Email, model.MasterPasswordHash, model.RecoveryCode))
|
if(!await _userService.RecoverTwoFactorAsync(model.Email, model.MasterPasswordHash, model.RecoveryCode))
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using Bit.Core.Models.Table;
|
||||||
|
|
||||||
|
namespace Bit.Core.Models.Api
|
||||||
|
{
|
||||||
|
public class TwoFactorRecoverResponseModel : ResponseModel
|
||||||
|
{
|
||||||
|
public TwoFactorRecoverResponseModel(User user)
|
||||||
|
: base("twoFactorRecover")
|
||||||
|
{
|
||||||
|
if(user == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(user));
|
||||||
|
}
|
||||||
|
|
||||||
|
Code = user.TwoFactorRecoveryCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Code { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,9 @@
|
|||||||
alter table [user] drop column twofactorenabled
|
alter table [user] drop column twofactorenabled
|
||||||
go
|
go
|
||||||
|
|
||||||
|
alter table [user] drop column [twofactorprovider]
|
||||||
|
go
|
||||||
|
|
||||||
drop view [dbo].[UserView]
|
drop view [dbo].[UserView]
|
||||||
go
|
go
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user