-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathUpdateMasterPasswordQuery.cs
More file actions
35 lines (28 loc) · 1.07 KB
/
UpdateMasterPasswordQuery.cs
File metadata and controls
35 lines (28 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using Bit.Core.Entities;
using Bit.Core.KeyManagement.MasterPassword.Interfaces;
using Bit.Core.KeyManagement.Models.Data;
using Microsoft.AspNetCore.Identity;
namespace Bit.Core.KeyManagement.MasterPassword;
/// <inheritdoc />
public class UpdateMasterPasswordQuery : IUpdateMasterPasswordQuery
{
private readonly IPasswordHasher<User> _passwordHasher;
public UpdateMasterPasswordQuery(IPasswordHasher<User> passwordHasher)
{
_passwordHasher = passwordHasher;
}
/// <inheritdoc />
public Task RunAsync(User user, UpdateMasterPasswordData data)
{
data.ValidateForUser(user);
user.MasterPassword = _passwordHasher.HashPassword(user,
data.MasterPasswordAuthentication.MasterPasswordAuthenticationHash);
user.MasterPasswordHint = data.MasterPasswordHint;
user.Key = data.MasterPasswordUnlock.MasterKeyWrappedUserKey;
var now = DateTime.UtcNow;
user.RevisionDate = now;
user.AccountRevisionDate = now;
user.LastPasswordChangeDate = now;
return Task.CompletedTask;
}
}