Example #1
0
        public async Task UpdateSettingsAsync(GithubAuthenticationSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            var container = await _siteService.GetSiteSettingsAsync();

            container.Alter <GithubAuthenticationSettings>(nameof(GithubAuthenticationSettings), aspect =>
            {
                aspect.ClientID     = settings.ClientID;
                aspect.ClientSecret = settings.ClientSecret;
                aspect.CallbackPath = settings.CallbackPath;
            });
            await _siteService.UpdateSiteSettingsAsync(container);
        }
Example #2
0
        public IEnumerable <ValidationResult> ValidateSettings(GithubAuthenticationSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            if (string.IsNullOrWhiteSpace(settings.ClientID))
            {
                yield return(new ValidationResult(T["ClientID is required"], new string[] { nameof(settings.ClientID) }));
            }

            if (string.IsNullOrWhiteSpace(settings.ClientSecret))
            {
                yield return(new ValidationResult(T["ClientSecret is required"], new string[] { nameof(settings.ClientSecret) }));
            }
        }