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