mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 16:42:50 -05:00
[PM-4168] update keys for WebAuthnLoginCredential (#3506)
* allow update of webauthnlogincredential * Added Tests * fixed tests to use commands * addressing various feedback items
This commit is contained in:
@ -34,4 +34,26 @@ public class WebAuthnCredentialRepository : Repository<Core.Auth.Entities.WebAut
|
||||
return Mapper.Map<List<Core.Auth.Entities.WebAuthnCredential>>(creds);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateAsync(Core.Auth.Entities.WebAuthnCredential credential)
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var cred = await dbContext.WebAuthnCredentials
|
||||
.FirstOrDefaultAsync(d => d.Id == credential.Id &&
|
||||
d.UserId == credential.UserId);
|
||||
if (cred == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
cred.EncryptedPrivateKey = credential.EncryptedPrivateKey;
|
||||
cred.EncryptedPublicKey = credential.EncryptedPublicKey;
|
||||
cred.EncryptedUserKey = credential.EncryptedUserKey;
|
||||
|
||||
await dbContext.SaveChangesAsync();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user