mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 16:42:50 -05:00
Added support for device registration during two factor login
This commit is contained in:
@ -96,7 +96,7 @@ namespace Bit.Core.Identity
|
||||
return await PasswordSignInAsync(user, password, device);
|
||||
}
|
||||
|
||||
public async Task<JwtBearerSignInResult> TwoFactorSignInAsync(User user, string provider, string code)
|
||||
public async Task<JwtBearerSignInResult> TwoFactorSignInAsync(User user, string provider, string code, Device device = null)
|
||||
{
|
||||
if(user == null)
|
||||
{
|
||||
@ -111,6 +111,13 @@ namespace Bit.Core.Identity
|
||||
success.Token = token;
|
||||
success.User = user;
|
||||
|
||||
var existingDevice = await _deviceRepository.GetByIdentifierAsync(device.Identifier, user.Id);
|
||||
if(existingDevice == null)
|
||||
{
|
||||
device.UserId = user.Id;
|
||||
await _deviceRepository.CreateAsync(device);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user