1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-09 03:53:15 +00:00

Merged master into PM-1575-display-passkeys

This commit is contained in:
Federico Maccaroni
2023-06-13 16:27:00 +02:00
88 changed files with 1012 additions and 491 deletions

View File

@@ -6,7 +6,8 @@ namespace Bit.Core.Abstractions
{
public interface IVaultTimeoutService
{
long? DelayLockAndLogoutMs { get; set; }
long? DelayTimeoutMs { get; set; }
bool ResetTimeoutDelay { get; set; }
Task CheckVaultTimeoutAsync();
Task<bool> ShouldTimeoutAsync(string userId = null);

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
@@ -975,7 +976,19 @@ namespace Bit.Core.Services
private bool IsJsonResponse(HttpResponseMessage response)
{
return (response.Content?.Headers?.ContentType?.MediaType ?? string.Empty) == "application/json";
if (response.Content?.Headers is null)
{
return false;
}
if (response.Content.Headers.ContentType?.MediaType == "application/json")
{
return true;
}
return response.Content.Headers.TryGetValues("Content-Type", out var vals)
&&
vals?.Any(v => v.Contains("application/json")) is true;
}
#endregion

View File

@@ -50,7 +50,8 @@ namespace Bit.Core.Services
_loggedOutCallback = loggedOutCallback;
}
public long? DelayLockAndLogoutMs { get; set; }
public long? DelayTimeoutMs { get; set; }
public bool ResetTimeoutDelay { get; set; }
public async Task<bool> IsLockedAsync(string userId = null)
{
@@ -117,7 +118,7 @@ namespace Bit.Core.Services
{
return false;
}
if (vaultTimeoutMinutes == 0 && !DelayLockAndLogoutMs.HasValue)
if (vaultTimeoutMinutes == 0 && !DelayTimeoutMs.HasValue)
{
return true;
}
@@ -127,8 +128,13 @@ namespace Bit.Core.Services
return false;
}
var diffMs = _platformUtilsService.GetActiveTime() - lastActiveTime;
if (DelayLockAndLogoutMs.HasValue && diffMs < DelayLockAndLogoutMs)
if (DelayTimeoutMs.HasValue && diffMs < DelayTimeoutMs)
{
if (ResetTimeoutDelay)
{
DelayTimeoutMs = null;
ResetTimeoutDelay = false;
}
return false;
}
var vaultTimeoutMs = vaultTimeoutMinutes * 60000;