public void Configure(PlatoFacebookOptions options)
        {
            var settings = _facebookSettingsStore
                           .GetAsync()
                           .GetAwaiter()
                           .GetResult();

            if (settings != null)
            {
                options.AppId = settings.AppId;

                // Decrypt the secret
                if (!String.IsNullOrWhiteSpace(settings.AppSecret))
                {
                    try
                    {
                        options.AppSecret = _encrypter.Decrypt(settings.AppSecret);
                    }
                    catch (Exception e)
                    {
                        if (_logger.IsEnabled(LogLevel.Error))
                        {
                            _logger.LogError(e, $"There was a problem decrypting the Facebook app secret. {e.Message}");
                        }
                    }
                }
            }
        }
Exemple #2
0
        public void Configure(FacebookOptions options)
        {
            var settings = _facebookSettingsStore
                           .GetAsync()
                           .GetAwaiter()
                           .GetResult();

            if (settings != null)
            {
                options.AppId = settings.AppId;

                // Decrypt the secret
                if (!String.IsNullOrWhiteSpace(settings.AppSecret))
                {
                    try
                    {
                        var protector = _dataProtectionProvider.CreateProtector(nameof(FacebookOptionsConfiguration));
                        options.AppSecret = protector.Unprotect(settings.AppSecret);
                    }
                    catch
                    {
                        _logger.LogError("There was a problem decrypting the SMTP password.");
                    }
                }
            }
        }
Exemple #3
0
        async Task <FacebookSettingsViewModel> GetModel()
        {
            var settings = await _facebookSettingsStore.GetAsync();

            if (settings != null)
            {
                // Decrypt the secret
                var secret = string.Empty;
                if (!string.IsNullOrWhiteSpace(settings.AppSecret))
                {
                    try
                    {
                        secret = _encrypter.Decrypt(settings.AppSecret);
                    }
                    catch (Exception e)
                    {
                        if (_logger.IsEnabled(LogLevel.Error))
                        {
                            _logger.LogError(e, $"There was a problem decrypting the Facebook app secret. {e.Message}");
                        }
                    }
                }

                return(new FacebookSettingsViewModel()
                {
                    AppId = _platoOptions.DemoMode ? "123456789" : settings.AppId,
                    AppSecret = _platoOptions.DemoMode ? "xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx" : secret,
                    CallbackPath = _platoOptions.DemoMode ? string.Empty : settings.CallbackPath.ToString()
                });
            }

            // return default settings
            return(new FacebookSettingsViewModel()
            {
                AppId = string.Empty,
                AppSecret = string.Empty
            });
        }
Exemple #4
0
        async Task <FacebookSettingsViewModel> GetModel()
        {
            var settings = await _facebookSettingsStore.GetAsync();

            if (settings != null)
            {
                // Decrypt the secret
                var secret = string.Empty;
                if (!string.IsNullOrWhiteSpace(settings.AppSecret))
                {
                    try
                    {
                        var protector = _dataProtectionProvider.CreateProtector(nameof(FacebookOptionsConfiguration));
                        secret = protector.Unprotect(settings.AppSecret);
                    }
                    catch (Exception e)
                    {
                        _logger.LogError($"There was a problem encrypting the Facebook app secret. {e.Message}");
                    }
                }


                return(new FacebookSettingsViewModel()
                {
                    AppId = settings.AppId,
                    AppSecret = secret
                });
            }

            // return default settings
            return(new FacebookSettingsViewModel()
            {
                AppId = string.Empty,
                AppSecret = string.Empty
            });
        }