public async Task <bool> AddBricksetPrimaryUser(string username, string password) { if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password) || !await _secureStorageService.IsBricksetApiKeyAcquired().ConfigureAwait(false) || await _secureStorageService.IsBricksetPrimaryUsersDefined().ConfigureAwait(false) || _bricksetUserRepository.Exists(username)) { return(false); } var bricksetUserHash = await _bricksetApiService.Login(new ParameterLogin { Username = username, Password = password, ApiKey = await _secureStorageService.GetBricksetApiKey().ConfigureAwait(false) }).ConfigureAwait(false); if (string.IsNullOrWhiteSpace(bricksetUserHash)) { return(false); } await _secureStorageService.SaveBricksetPrimaryUser(username, bricksetUserHash).ConfigureAwait(false); _bricksetUserRepository.Add(BricksetUserType.Primary, username); await _userSynchronizationService.SynchronizeBricksetPrimaryUsersSets(username).ConfigureAwait(false); return(true); }
public async Task <string> GetBricksetApiKey() { var bricksetApiKey = await _secureStorageService.GetBricksetApiKey().ConfigureAwait(false); if (string.IsNullOrWhiteSpace(bricksetApiKey)) { bricksetApiKey = await GetApiKeyFromOnboardingServiceEndpoint().ConfigureAwait(false); await _secureStorageService.SaveBricksetApiKey(bricksetApiKey).ConfigureAwait(false); } return(bricksetApiKey); }
public async Task <bool> InstallAllMyBricksSeedDatabase(string databaseSeedUrl, string targetFolderPath) { if ((!string.IsNullOrWhiteSpace(targetFolderPath) && !_directory.Exists(targetFolderPath)) || string.IsNullOrWhiteSpace(databaseSeedUrl) || !(Uri.TryCreate(databaseSeedUrl, UriKind.Absolute, out Uri uriResult) && (uriResult.Scheme == Uri.UriSchemeHttps || uriResult.Scheme == Uri.UriSchemeHttp) && uriResult.Segments.Length > 1)) { return(false); } return(_assetUncompression.UncompressAsset(await databaseSeedUrl.GetStreamAsync().ConfigureAwait(false), targetFolderPath ?? string.Empty, encryptionKey: await _secureStorageService.GetBricksetApiKey().ConfigureAwait(false))); }