async Task <GoogleSettingsViewModel> GetModel() { var settings = await _googleSettingsStore.GetAsync(); if (settings != null) { // Decrypt the secret var secret = string.Empty; if (!string.IsNullOrWhiteSpace(settings.ClientSecret)) { try { secret = _encrypter.Decrypt(settings.ClientSecret); } catch (Exception e) { if (_logger.IsEnabled(LogLevel.Error)) { _logger.LogError(e, $"There was a problem decrypting the Google client secret. {e.Message}"); } } } return(new GoogleSettingsViewModel() { ClientId = _platoOptions.DemoMode ? "123456789" : settings.ClientId, ClientSecret = _platoOptions.DemoMode ? "xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx" : secret, CallbackPath = _platoOptions.DemoMode ? string.Empty : settings.CallbackPath.ToString(), TrackingId = _platoOptions.DemoMode ? "UA-123456789-0" : settings.TrackingId }); } // return default settings return(new GoogleSettingsViewModel() { ClientId = string.Empty, ClientSecret = string.Empty, CallbackPath = string.Empty, TrackingId = string.Empty }); }
public void Configure(PlatoGoogleOptions options) { var settings = _googleSettingsStore .GetAsync() .GetAwaiter() .GetResult(); if (settings != null) { // Authentication options.ClientId = settings.ClientId; // Decrypt the secret if (!String.IsNullOrWhiteSpace(settings.ClientSecret)) { try { options.ClientSecret = _encrypter.Decrypt(settings.ClientSecret); } catch (Exception e) { if (_logger.IsEnabled(LogLevel.Error)) { _logger.LogError(e, $"There was a problem decrypting the Google client secret. {e.Message}"); } } } if (settings.CallbackPath.HasValue) { options.CallbackPath = settings.CallbackPath; } // Analytics options.TrackingId = settings.TrackingId; } }