mirror of
https://github.com/bitwarden/android.git
synced 2025-01-11 18:57:39 +03:00
Use UserService to manage emailVerified (#1367)
This commit is contained in:
parent
75e27ffbe3
commit
3b2b37b3b0
4 changed files with 21 additions and 3 deletions
|
@ -21,7 +21,6 @@ namespace Bit.App.Pages
|
|||
private readonly IMessagingService _messagingService;
|
||||
private readonly IUserService _userService;
|
||||
private readonly ISendService _sendService;
|
||||
private readonly ITokenService _tokenService;
|
||||
private bool _sendEnabled;
|
||||
private bool _canAccessPremium;
|
||||
private bool _emailVerified;
|
||||
|
@ -55,7 +54,6 @@ namespace Bit.App.Pages
|
|||
_messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
|
||||
_userService = ServiceContainer.Resolve<IUserService>("userService");
|
||||
_sendService = ServiceContainer.Resolve<ISendService>("sendService");
|
||||
_tokenService = ServiceContainer.Resolve<ITokenService>("tokenService");
|
||||
TogglePasswordCommand = new Command(TogglePassword);
|
||||
|
||||
TypeOptions = new List<KeyValuePair<string, SendType>>
|
||||
|
@ -224,7 +222,7 @@ namespace Bit.App.Pages
|
|||
{
|
||||
PageTitle = EditMode ? AppResources.EditSend : AppResources.AddSend;
|
||||
_canAccessPremium = await _userService.CanAccessPremiumAsync();
|
||||
_emailVerified = _tokenService.GetEmailVerified();
|
||||
_emailVerified = await _userService.GetEmailVerifiedAsync();
|
||||
SendEnabled = ! await AppHelpers.IsSendDisabledByPolicyAsync();
|
||||
DisableHideEmail = await AppHelpers.IsHideEmailDisabledByPolicyAsync();
|
||||
SendOptionsPolicyInEffect = SendEnabled && DisableHideEmail;
|
||||
|
|
|
@ -17,10 +17,12 @@ namespace Bit.Core.Abstractions
|
|||
Task<int?> GetKdfIterationsAsync();
|
||||
Task<Organization> GetOrganizationAsync(string id);
|
||||
Task<string> GetSecurityStampAsync();
|
||||
Task<bool> GetEmailVerifiedAsync();
|
||||
Task<string> GetUserIdAsync();
|
||||
Task<bool> IsAuthenticatedAsync();
|
||||
Task ReplaceOrganizationsAsync(Dictionary<string, OrganizationData> organizations);
|
||||
Task SetInformationAsync(string userId, string email, KdfType kdf, int? kdfIterations);
|
||||
Task SetSecurityStampAsync(string stamp);
|
||||
Task SetEmailVerifiedAsync(bool emailVerified);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -327,6 +327,7 @@ namespace Bit.Core.Services
|
|||
await _userService.SetSecurityStampAsync(response.SecurityStamp);
|
||||
var organizations = response.Organizations.ToDictionary(o => o.Id, o => new OrganizationData(o));
|
||||
await _userService.ReplaceOrganizationsAsync(organizations);
|
||||
await _userService.SetEmailVerifiedAsync(response.EmailVerified);
|
||||
}
|
||||
|
||||
private async Task SyncFoldersAsync(string userId, List<FolderResponse> response)
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Bit.Core.Services
|
|||
private string _stamp;
|
||||
private KdfType? _kdf;
|
||||
private int? _kdfIterations;
|
||||
private bool? _emailVerified;
|
||||
|
||||
private const string Keys_UserId = "userId";
|
||||
private const string Keys_UserEmail = "userEmail";
|
||||
|
@ -22,6 +23,7 @@ namespace Bit.Core.Services
|
|||
private const string Keys_Kdf = "kdf";
|
||||
private const string Keys_KdfIterations = "kdfIterations";
|
||||
private const string Keys_OrganizationsFormat = "organizations_{0}";
|
||||
private const string Keys_EmailVerified = "emailVerified";
|
||||
|
||||
private readonly IStorageService _storageService;
|
||||
private readonly ITokenService _tokenService;
|
||||
|
@ -51,6 +53,12 @@ namespace Bit.Core.Services
|
|||
await _storageService.SaveAsync(Keys_Stamp, stamp);
|
||||
}
|
||||
|
||||
public async Task SetEmailVerifiedAsync(bool emailVerified)
|
||||
{
|
||||
_emailVerified = emailVerified;
|
||||
await _storageService.SaveAsync(Keys_EmailVerified, emailVerified);
|
||||
}
|
||||
|
||||
public async Task<string> GetUserIdAsync()
|
||||
{
|
||||
if (_userId == null)
|
||||
|
@ -78,6 +86,15 @@ namespace Bit.Core.Services
|
|||
return _stamp;
|
||||
}
|
||||
|
||||
public async Task<bool> GetEmailVerifiedAsync()
|
||||
{
|
||||
if (_emailVerified == null)
|
||||
{
|
||||
_emailVerified = await _storageService.GetAsync<bool>(Keys_EmailVerified);
|
||||
}
|
||||
return _emailVerified.GetValueOrDefault();
|
||||
}
|
||||
|
||||
public async Task<KdfType?> GetKdfAsync()
|
||||
{
|
||||
if (_kdf == null)
|
||||
|
|
Loading…
Reference in a new issue