Ejemplo n.º 1
0
        /// <summary>
        /// 获取外部认证设置
        /// </summary>
        /// <returns></returns>
        private async Task <ExternalAuthenticationEditDto> GetExternalAuthenticationsAsync()
        {
            var providers = _appConfiguration["Authentication:Provider"];

            var externalAuthentication = new ExternalAuthenticationEditDto()
            {
                UserActivationId        = await SettingManager.GetSettingValueAsync <int>(AppSettings.ExternalAuthentication.UserActivation),
                RequiredUserName        = await SettingManager.GetSettingValueAsync <bool>(AppSettings.ExternalAuthentication.UserActivationCondition.RequiredUserName),
                RequiredEmail           = await SettingManager.GetSettingValueAsync <bool>(AppSettings.ExternalAuthentication.UserActivationCondition.RequiredEmail),
                RequiredTelephone       = await SettingManager.GetSettingValueAsync <bool>(AppSettings.ExternalAuthentication.UserActivationCondition.RequiredTelephone),
                UseTelephoneforUsername = await SettingManager.GetSettingValueAsync <bool>(AppSettings.ExternalAuthentication.UserActivationCondition.UseTelephoneforUsername),
            };

            if (!providers.IsNullOrEmpty())
            {
                foreach (var provider in providers.Split(','))
                {
                    var item = new ExternalAuthenticationProviderEditDto()
                    {
                        ProviderName = provider,
                    };

                    var itemString = await SettingManager.GetSettingValueAsync(string.Format(AppSettings.ExternalAuthentication.ProviderName, provider));

                    if (!itemString.IsNullOrEmpty())
                    {
                        item = JsonConvert.DeserializeObject <ExternalAuthenticationProviderEditDto>(itemString);
                    }

                    externalAuthentication.ExternalAuthenticationProviders.Add(item);
                }
            }

            return(externalAuthentication);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取外部认证设置
        /// </summary>
        /// <returns></returns>
        private async Task <ExternalAuthenticationEditDto> GetExternalAuthenticationsAsync()
        {
            var externalAuthentication = new ExternalAuthenticationEditDto()
            {
                UserActivationId        = await SettingManager.GetSettingValueAsync <int>(AppSettings.ExternalAuthentication.UserActivation),
                RequiredUserName        = await SettingManager.GetSettingValueAsync <bool>(AppSettings.ExternalAuthentication.UserActivationCondition.RequiredUserName),
                RequiredEmail           = await SettingManager.GetSettingValueAsync <bool>(AppSettings.ExternalAuthentication.UserActivationCondition.RequiredEmail),
                RequiredTelephone       = await SettingManager.GetSettingValueAsync <bool>(AppSettings.ExternalAuthentication.UserActivationCondition.RequiredTelephone),
                UseTelephoneforUsername = await SettingManager.GetSettingValueAsync <bool>(AppSettings.ExternalAuthentication.UserActivationCondition.UseTelephoneforUsername),
            };

            return(externalAuthentication);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新外部登陆
        /// </summary>
        /// <param name="settings"></param>
        /// <returns></returns>
        private async Task UpdateExternalAuthenticationsAsync(ExternalAuthenticationEditDto settings)
        {
            await SettingManager.ChangeSettingForApplicationAsync(AppSettings.ExternalAuthentication.UserActivation,
                                                                  settings.UserActivationId.ToString());

            await SettingManager.ChangeSettingForApplicationAsync(AppSettings.ExternalAuthentication.UserActivationCondition.RequiredEmail,
                                                                  settings.RequiredEmail.ToLowerString());

            await SettingManager.ChangeSettingForApplicationAsync(AppSettings.ExternalAuthentication.UserActivationCondition.RequiredUserName,
                                                                  settings.RequiredUserName.ToLowerString());

            await SettingManager.ChangeSettingForApplicationAsync(AppSettings.ExternalAuthentication.UserActivationCondition.RequiredTelephone,
                                                                  settings.RequiredTelephone.ToLowerString());

            await SettingManager.ChangeSettingForApplicationAsync(AppSettings.ExternalAuthentication.UserActivationCondition.UseTelephoneforUsername,
                                                                  settings.UseTelephoneforUsername.ToLowerString());
        }