Пример #1
0
        public async Task <ActionResult> ExecuteAsync(AuthenticationProvider authenticationProvider)
        {
            if (authenticationProvider == null)
            {
                throw new ArgumentNullException(nameof(authenticationProvider));
            }

            var authProvider = await _authenticationProviderRepository.GetAuthenticationProvider(authenticationProvider.Name);

            if (authProvider == null)
            {
                return(new NotFoundResult());
            }

            var isUpdated = await _authenticationProviderRepository.UpdateAuthenticationProvider(authenticationProvider);

            if (isUpdated)
            {
                return(new NoContentResult());
            }

            return(new StatusCodeResult(StatusCodes.Status500InternalServerError));
        }
Пример #2
0
        public async Task<ActionResult> ExecuteAsync(string name, bool isEnabled)
        {
            _configurationEventSource.EnableAuthenticationProvider(name, isEnabled);
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            var authProvider = await _authenticationProviderRepository.GetAuthenticationProvider(name);
            if (authProvider == null)
            {
                return new NotFoundResult();
            }

            authProvider.IsEnabled = isEnabled;
            var isUpdated = await _authenticationProviderRepository.UpdateAuthenticationProvider(authProvider);
            if (isUpdated)
            {
                _configurationEventSource.FinishToEnableAuthenticationProvider(name, isEnabled);
                return new NoContentResult();
            }

            return new StatusCodeResult(StatusCodes.Status500InternalServerError);
        }