mirror of
https://github.com/bitwarden/server.git
synced 2025-04-08 06:28:14 -05:00
[Reset Password v1] Updated force password reset models (#1492)
This commit is contained in:
parent
152f1f7a9b
commit
53a93ffcea
@ -799,8 +799,8 @@ namespace Bit.Api.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("update-temp-password")]
|
[HttpPut("update-temp-password")]
|
||||||
public async Task PostUpdateTempPasswordAsync([FromBody]UpdateTempPasswordRequestModel model)
|
public async Task PutUpdateTempPasswordAsync([FromBody]UpdateTempPasswordRequestModel model)
|
||||||
{
|
{
|
||||||
var user = await _userService.GetUserByPrincipalAsync(User);
|
var user = await _userService.GetUserByPrincipalAsync(User);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
@ -808,7 +808,7 @@ namespace Bit.Api.Controllers
|
|||||||
throw new UnauthorizedAccessException();
|
throw new UnauthorizedAccessException();
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = await _userService.UpdateTempPasswordAsync(user, model.NewMasterPasswordHash, model.Key);
|
var result = await _userService.UpdateTempPasswordAsync(user, model.NewMasterPasswordHash, model.Key, model.MasterPasswordHint);
|
||||||
if (result.Succeeded)
|
if (result.Succeeded)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
namespace Bit.Core.Models.Api.Request.Accounts
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace Bit.Core.Models.Api.Request.Accounts
|
||||||
{
|
{
|
||||||
public class UpdateTempPasswordRequestModel : OrganizationUserResetPasswordRequestModel
|
public class UpdateTempPasswordRequestModel : OrganizationUserResetPasswordRequestModel
|
||||||
{
|
{
|
||||||
|
[StringLength(50)]
|
||||||
|
public string MasterPasswordHint { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ namespace Bit.Core.Services
|
|||||||
Task<IdentityResult> ChangePasswordAsync(User user, string masterPassword, string newMasterPassword, string key);
|
Task<IdentityResult> ChangePasswordAsync(User user, string masterPassword, string newMasterPassword, string key);
|
||||||
Task<IdentityResult> SetPasswordAsync(User user, string newMasterPassword, string key, string orgIdentifier = null);
|
Task<IdentityResult> SetPasswordAsync(User user, string newMasterPassword, string key, string orgIdentifier = null);
|
||||||
Task<IdentityResult> AdminResetPasswordAsync(OrganizationUserType type, Guid orgId, Guid id, string newMasterPassword, string key);
|
Task<IdentityResult> AdminResetPasswordAsync(OrganizationUserType type, Guid orgId, Guid id, string newMasterPassword, string key);
|
||||||
Task<IdentityResult> UpdateTempPasswordAsync(User user, string newMasterPassword, string key);
|
Task<IdentityResult> UpdateTempPasswordAsync(User user, string newMasterPassword, string key, string hint);
|
||||||
Task<IdentityResult> ChangeKdfAsync(User user, string masterPassword, string newMasterPassword, string key,
|
Task<IdentityResult> ChangeKdfAsync(User user, string masterPassword, string newMasterPassword, string key,
|
||||||
KdfType kdf, int kdfIterations);
|
KdfType kdf, int kdfIterations);
|
||||||
Task<IdentityResult> UpdateKeyAsync(User user, string masterPassword, string key, string privateKey,
|
Task<IdentityResult> UpdateKeyAsync(User user, string masterPassword, string key, string privateKey,
|
||||||
|
@ -700,7 +700,7 @@ namespace Bit.Core.Services
|
|||||||
return IdentityResult.Success;
|
return IdentityResult.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IdentityResult> UpdateTempPasswordAsync(User user, string newMasterPassword, string key)
|
public async Task<IdentityResult> UpdateTempPasswordAsync(User user, string newMasterPassword, string key, string hint)
|
||||||
{
|
{
|
||||||
if (!user.ForcePasswordReset)
|
if (!user.ForcePasswordReset)
|
||||||
{
|
{
|
||||||
@ -716,6 +716,7 @@ namespace Bit.Core.Services
|
|||||||
user.RevisionDate = user.AccountRevisionDate = DateTime.UtcNow;
|
user.RevisionDate = user.AccountRevisionDate = DateTime.UtcNow;
|
||||||
user.ForcePasswordReset = false;
|
user.ForcePasswordReset = false;
|
||||||
user.Key = key;
|
user.Key = key;
|
||||||
|
user.MasterPasswordHint = hint;
|
||||||
|
|
||||||
await _userRepository.ReplaceAsync(user);
|
await _userRepository.ReplaceAsync(user);
|
||||||
await _mailService.SendUpdatedTempPasswordEmailAsync(user.Email, user.Name ?? user.Email);
|
await _mailService.SendUpdatedTempPasswordEmailAsync(user.Email, user.Name ?? user.Email);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user