1
0
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:
Kyle Spearrin
2016-07-23 02:49:57 -04:00
parent 452d74a266
commit d300c82ffd
3 changed files with 10 additions and 2 deletions

View File

@ -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;
}