mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-28 12:35:40 +01:00
Merge branch 'master' into bugfix/helper-activities-launchmode
This commit is contained in:
commit
f52e5ce5e9
@ -3,7 +3,6 @@ using System.Threading.Tasks;
|
|||||||
using Bit.Core.Abstractions;
|
using Bit.Core.Abstractions;
|
||||||
using Bit.Core.Enums;
|
using Bit.Core.Enums;
|
||||||
using Bit.Core.Exceptions;
|
using Bit.Core.Exceptions;
|
||||||
using Bit.Core.Models.Domain;
|
|
||||||
|
|
||||||
namespace Bit.Core.Services
|
namespace Bit.Core.Services
|
||||||
{
|
{
|
||||||
@ -56,8 +55,15 @@ namespace Bit.Core.Services
|
|||||||
|
|
||||||
public long? DelayLockAndLogoutMs { get; set; }
|
public long? DelayLockAndLogoutMs { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determine if the current or provided account is locked.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId">
|
||||||
|
/// Optional specified user, must be provided if not the current account.
|
||||||
|
/// </param>
|
||||||
public async Task<bool> IsLockedAsync(string userId = null)
|
public async Task<bool> IsLockedAsync(string userId = null)
|
||||||
{
|
{
|
||||||
|
// If biometrics are used, we can use the flag to determine locked state
|
||||||
var biometricSet = await IsBiometricLockSetAsync(userId);
|
var biometricSet = await IsBiometricLockSetAsync(userId);
|
||||||
if (biometricSet && await _stateService.GetBiometricLockedAsync(userId))
|
if (biometricSet && await _stateService.GetBiometricLockedAsync(userId))
|
||||||
{
|
{
|
||||||
@ -68,18 +74,21 @@ namespace Bit.Core.Services
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// Filter out accounts without auto key
|
||||||
if (!await _cryptoService.HasAutoUnlockKeyAsync(userId))
|
if (!await _cryptoService.HasAutoUnlockKeyAsync(userId))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// Inactive accounts with an auto key aren't locked, but we shouldn't set user key
|
||||||
if (userId != null && await _stateService.GetActiveUserIdAsync() != userId)
|
if (userId != null && await _stateService.GetActiveUserIdAsync() != userId)
|
||||||
{
|
{
|
||||||
await _cryptoService.SetUserKeyAsync(await _cryptoService.GetAutoUnlockKeyAsync(userId),
|
return false;
|
||||||
userId);
|
|
||||||
}
|
}
|
||||||
|
await _cryptoService.SetUserKeyAsync(await _cryptoService.GetAutoUnlockKeyAsync(userId), userId);
|
||||||
}
|
}
|
||||||
catch (LegacyUserException)
|
catch (LegacyUserException)
|
||||||
{
|
{
|
||||||
|
// Legacy users must migrate on web vault before login
|
||||||
await LogOutAsync(false, userId);
|
await LogOutAsync(false, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user