mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-27 12:26:31 +01:00
Set push token state values to be user-specific (#2200)
* Changed the current push token and last registration time to be user-based * Fixed compile error. * Fixed interface implementation. * Fixed compile error for Android. * Refactored to handle getting active user ID within state service * Refactored methods allow existing logic to handle getting the active user. * Updated to reconcile options. * Updated naming and fixed issue with UserId. * Removed space between constants.
This commit is contained in:
parent
37dab0928b
commit
ebf65ecb96
@ -19,9 +19,7 @@ namespace Bit.App.Services
|
||||
Constants.AddSitePromptShownKey,
|
||||
Constants.PushInitialPromptShownKey,
|
||||
Constants.LastFileCacheClearKey,
|
||||
Constants.PushLastRegistrationDateKey,
|
||||
Constants.PushRegisteredTokenKey,
|
||||
Constants.PushCurrentTokenKey,
|
||||
Constants.LastBuildKey,
|
||||
Constants.ClearCiphersCacheKey,
|
||||
Constants.BiometricIntegrityKey,
|
||||
|
@ -119,12 +119,12 @@ namespace Bit.Core.Abstractions
|
||||
Task SetAddSitePromptShownAsync(bool? value, string userId = null);
|
||||
Task<bool?> GetPushInitialPromptShownAsync();
|
||||
Task SetPushInitialPromptShownAsync(bool? value);
|
||||
Task<DateTime?> GetPushLastRegistrationDateAsync();
|
||||
Task SetPushLastRegistrationDateAsync(DateTime? value);
|
||||
Task<DateTime?> GetPushLastRegistrationDateAsync(string userId = null);
|
||||
Task SetPushLastRegistrationDateAsync(DateTime? value, string userId = null);
|
||||
Task<string> GetPushInstallationRegistrationErrorAsync();
|
||||
Task SetPushInstallationRegistrationErrorAsync(string value);
|
||||
Task<string> GetPushCurrentTokenAsync();
|
||||
Task SetPushCurrentTokenAsync(string value);
|
||||
Task<string> GetPushCurrentTokenAsync(string userId = null);
|
||||
Task SetPushCurrentTokenAsync(string value, string userId = null);
|
||||
Task<List<EventData>> GetEventCollectionAsync();
|
||||
Task SetEventCollectionAsync(List<EventData> value);
|
||||
Task<Dictionary<string, FolderData>> GetEncryptedFoldersAsync(string userId = null);
|
||||
|
@ -12,8 +12,6 @@
|
||||
public static string LastFileCacheClearKey = "lastFileCacheClear";
|
||||
public static string AutofillTileAdded = "autofillTileAdded";
|
||||
public static string PushRegisteredTokenKey = "pushRegisteredToken";
|
||||
public static string PushCurrentTokenKey = "pushCurrentToken";
|
||||
public static string PushLastRegistrationDateKey = "pushLastRegistrationDate";
|
||||
public static string PushInitialPromptShownKey = "pushInitialPromptShown";
|
||||
public static string PushInstallationRegistrationErrorKey = "pushInstallationRegistrationError";
|
||||
public static string LastBuildKey = "lastBuild";
|
||||
@ -96,6 +94,8 @@
|
||||
public static string BiometricUnlockKey(string userId) => $"biometricUnlock_{userId}";
|
||||
public static string ApprovePasswordlessLoginsKey(string userId) => $"approvePasswordlessLogins_{userId}";
|
||||
public static string UsernameGenOptionsKey(string userId) => $"usernameGenerationOptions_{userId}";
|
||||
public static string PushLastRegistrationDateKey(string userId) => $"pushLastRegistrationDate_{userId}";
|
||||
public static string PushCurrentTokenKey(string userId) => $"pushCurrentToken_{userId}";
|
||||
public static string ShouldConnectToWatchKey(string userId) => $"shouldConnectToWatch_{userId}";
|
||||
}
|
||||
}
|
||||
|
@ -1009,18 +1009,18 @@ namespace Bit.Core.Services
|
||||
await SetValueAsync(key, value, options);
|
||||
}
|
||||
|
||||
public async Task<DateTime?> GetPushLastRegistrationDateAsync()
|
||||
public async Task<DateTime?> GetPushLastRegistrationDateAsync(string userId = null)
|
||||
{
|
||||
var options = await GetDefaultStorageOptionsAsync();
|
||||
var key = Constants.PushLastRegistrationDateKey;
|
||||
return await GetValueAsync<DateTime?>(key, options);
|
||||
var reconciledOptions = ReconcileOptions(new StorageOptions { UserId = userId }, await GetDefaultStorageOptionsAsync());
|
||||
var key = Constants.PushLastRegistrationDateKey(reconciledOptions.UserId);
|
||||
return await GetValueAsync<DateTime?>(key, reconciledOptions);
|
||||
}
|
||||
|
||||
public async Task SetPushLastRegistrationDateAsync(DateTime? value)
|
||||
public async Task SetPushLastRegistrationDateAsync(DateTime? value, string userId = null)
|
||||
{
|
||||
var options = await GetDefaultStorageOptionsAsync();
|
||||
var key = Constants.PushLastRegistrationDateKey;
|
||||
await SetValueAsync(key, value, options);
|
||||
var reconciledOptions = ReconcileOptions(new StorageOptions { UserId = userId }, await GetDefaultStorageOptionsAsync());
|
||||
var key = Constants.PushLastRegistrationDateKey(reconciledOptions.UserId);
|
||||
await SetValueAsync(key, value, reconciledOptions);
|
||||
}
|
||||
|
||||
public async Task<string> GetPushInstallationRegistrationErrorAsync()
|
||||
@ -1037,18 +1037,18 @@ namespace Bit.Core.Services
|
||||
await SetValueAsync(key, value, options);
|
||||
}
|
||||
|
||||
public async Task<string> GetPushCurrentTokenAsync()
|
||||
public async Task<string> GetPushCurrentTokenAsync(string userId = null)
|
||||
{
|
||||
var options = await GetDefaultStorageOptionsAsync();
|
||||
var key = Constants.PushCurrentTokenKey;
|
||||
return await GetValueAsync<string>(key, options);
|
||||
var reconciledOptions = ReconcileOptions(new StorageOptions { UserId = userId }, await GetDefaultStorageOptionsAsync());
|
||||
var key = Constants.PushCurrentTokenKey(reconciledOptions.UserId);
|
||||
return await GetValueAsync<string>(key, reconciledOptions);
|
||||
}
|
||||
|
||||
public async Task SetPushCurrentTokenAsync(string value)
|
||||
public async Task SetPushCurrentTokenAsync(string value, string userId = null)
|
||||
{
|
||||
var options = await GetDefaultStorageOptionsAsync();
|
||||
var key = Constants.PushCurrentTokenKey;
|
||||
await SetValueAsync(key, value, options);
|
||||
var reconciledOptions = ReconcileOptions(new StorageOptions { UserId = userId }, await GetDefaultStorageOptionsAsync());
|
||||
var key = Constants.PushCurrentTokenKey(reconciledOptions.UserId);
|
||||
await SetValueAsync(key, value, reconciledOptions);
|
||||
}
|
||||
|
||||
public async Task<List<EventData>> GetEventCollectionAsync()
|
||||
|
Loading…
Reference in New Issue
Block a user