private async Task ProcessLoginSuccessAsync(SymmetricCryptoKey key, TokenResponse response) { if (response.Key != null) { _cryptoService.SetEncKey(new CipherString(response.Key)); } if (response.PrivateKey != null) { _cryptoService.SetPrivateKey(new CipherString(response.PrivateKey)); } _cryptoService.Key = key; _tokenService.Token = response.AccessToken; _tokenService.RefreshToken = response.RefreshToken; UserId = _tokenService.TokenUserId; Email = _tokenService.TokenEmail; _settings.AddOrUpdateValue(Constants.LastLoginEmail, Email); if (response.PrivateKey != null) { var profile = await _accountsApiRepository.GetProfileAsync(); if (profile.Succeeded) { _cryptoService.SetOrgKeys(profile.Result); } } if (!string.IsNullOrWhiteSpace(response.TwoFactorToken)) { _tokenService.SetTwoFactorToken(_tokenService.TokenEmail, response.TwoFactorToken); } }
public async Task <bool> SyncProfileAsync() { if (!_authService.IsAuthenticated) { return(false); } SyncStarted(); var profile = await _accountsApiRepository.GetProfileAsync().ConfigureAwait(false); if (!CheckSuccess(profile)) { return(false); } await SyncOrgKeysAsync(profile.Result); SyncCompleted(true); return(true); }
public async Task <bool> SyncProfileAsync() { if (!_authService.IsAuthenticated) { return(false); } SyncStarted(); var profile = await _accountsApiRepository.GetProfileAsync().ConfigureAwait(false); if (!CheckSuccess(profile, !string.IsNullOrWhiteSpace(_appSettingsService.SecurityStamp) && _appSettingsService.SecurityStamp != profile.Result.SecurityStamp)) { return(false); } await SyncProfileKeysAsync(profile.Result); SyncCompleted(true); return(true); }
private async Task ProcessLoginSuccessAsync(SymmetricCryptoKey key, TokenResponse response) { if (response.Key != null) { _cryptoService.SetEncKey(new CipherString(response.Key)); } if (response.PrivateKey != null) { _cryptoService.SetPrivateKey(new CipherString(response.PrivateKey)); } _cryptoService.Key = key; _tokenService.Token = response.AccessToken; _tokenService.RefreshToken = response.RefreshToken; UserId = _tokenService.TokenUserId; Email = _tokenService.TokenEmail; _settings.AddOrUpdateValue(Constants.LastLoginEmail, Email); _appSettingsService.FailedPinAttempts = 0; _appSettingsService.OrganizationGivesPremium = false; if (response.PrivateKey != null) { var profile = await _accountsApiRepository.GetProfileAsync(); if (profile.Succeeded) { _cryptoService.SetOrgKeys(profile.Result); _appSettingsService.OrganizationGivesPremium = profile.Result?.Organizations?.Any(o => o.UsersGetPremium && o.Enabled) ?? false; } } if (!string.IsNullOrWhiteSpace(response.TwoFactorToken)) { _tokenService.SetTwoFactorToken(_tokenService.TokenEmail, response.TwoFactorToken); } }