23 changed files with 769 additions and 105 deletions
@ -1,23 +1,77 @@ |
|||
using Microsoft.AspNetCore.Identity; |
|||
using Microsoft.Extensions.Options; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Identity.Settings; |
|||
using Volo.Abp.Options; |
|||
using Volo.Abp.Settings; |
|||
using Volo.Abp.Threading; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class AbpIdentityOverrideOptionsFactory : AbpOptionsFactory<IdentityOptions> |
|||
{ |
|||
protected ISettingStore SettingStore { get; } |
|||
public AbpIdentityOverrideOptionsFactory( |
|||
ISettingStore settingStore, |
|||
IEnumerable<IConfigureOptions<IdentityOptions>> setups, |
|||
IEnumerable<IPostConfigureOptions<IdentityOptions>> postConfigures) |
|||
: base(setups, postConfigures) |
|||
{ |
|||
|
|||
SettingStore = settingStore; |
|||
} |
|||
|
|||
public override IdentityOptions Create(string name) |
|||
{ |
|||
return base.Create(name); |
|||
var options = base.Create(name); |
|||
|
|||
// 重写为只获取公共配置
|
|||
OverrideOptions(options); |
|||
|
|||
return options; |
|||
} |
|||
|
|||
protected virtual void OverrideOptions(IdentityOptions options) |
|||
{ |
|||
AsyncHelper.RunSync(() => OverrideOptionsAsync(options)); |
|||
} |
|||
|
|||
protected virtual async Task OverrideOptionsAsync(IdentityOptions options) |
|||
{ |
|||
options.Password.RequiredLength = await GetOrDefaultAsync(IdentitySettingNames.Password.RequiredLength, options.Password.RequiredLength); |
|||
options.Password.RequiredUniqueChars = await GetOrDefaultAsync(IdentitySettingNames.Password.RequiredUniqueChars, options.Password.RequiredUniqueChars); |
|||
options.Password.RequireNonAlphanumeric = await GetOrDefaultAsync(IdentitySettingNames.Password.RequireNonAlphanumeric, options.Password.RequireNonAlphanumeric); |
|||
options.Password.RequireLowercase = await GetOrDefaultAsync(IdentitySettingNames.Password.RequireLowercase, options.Password.RequireLowercase); |
|||
options.Password.RequireUppercase = await GetOrDefaultAsync(IdentitySettingNames.Password.RequireUppercase, options.Password.RequireUppercase); |
|||
options.Password.RequireDigit = await GetOrDefaultAsync(IdentitySettingNames.Password.RequireDigit, options.Password.RequireDigit); |
|||
|
|||
options.Lockout.AllowedForNewUsers = await GetOrDefaultAsync(IdentitySettingNames.Lockout.AllowedForNewUsers, options.Lockout.AllowedForNewUsers); |
|||
options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromSeconds(await GetOrDefaultAsync(IdentitySettingNames.Lockout.LockoutDuration, options.Lockout.DefaultLockoutTimeSpan.TotalSeconds.To<int>())); |
|||
options.Lockout.MaxFailedAccessAttempts = await GetOrDefaultAsync(IdentitySettingNames.Lockout.MaxFailedAccessAttempts, options.Lockout.MaxFailedAccessAttempts); |
|||
|
|||
options.SignIn.RequireConfirmedEmail = await GetOrDefaultAsync(IdentitySettingNames.SignIn.RequireConfirmedEmail, options.SignIn.RequireConfirmedEmail); |
|||
options.SignIn.RequireConfirmedPhoneNumber = await GetOrDefaultAsync(IdentitySettingNames.SignIn.RequireConfirmedPhoneNumber, options.SignIn.RequireConfirmedPhoneNumber); |
|||
} |
|||
|
|||
protected virtual async Task<T> GetOrDefaultAsync<T>(string name, T defaultValue = default(T)) where T : struct |
|||
{ |
|||
var setting = await SettingStore.GetOrNullAsync(name, GlobalSettingValueProvider.ProviderName, null); |
|||
if (setting.IsNullOrWhiteSpace()) |
|||
{ |
|||
return defaultValue; |
|||
} |
|||
return setting.To<T>(); |
|||
} |
|||
|
|||
protected virtual async Task<string> GetOrDefaultAsync(string name, string defaultValue = "") |
|||
{ |
|||
var setting = await SettingStore.GetOrNullAsync(name, GlobalSettingValueProvider.ProviderName, null); |
|||
if (setting.IsNullOrWhiteSpace()) |
|||
{ |
|||
return defaultValue; |
|||
} |
|||
return setting; |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,8 @@ |
|||
@echo off |
|||
cls |
|||
chcp 65001 |
|||
|
|||
echo. 启动平台管理服务 |
|||
|
|||
cd .\platform\LINGYUN.Platform.HttpApi.Host |
|||
|
|||
@ -0,0 +1,268 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Localization; |
|||
using Microsoft.Extensions.Logging; |
|||
using Microsoft.Extensions.Options; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Globalization; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; |
|||
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; |
|||
using Volo.Abp.AspNetCore.Mvc.MultiTenancy; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.Clients; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.EventBus.Local; |
|||
using Volo.Abp.Features; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.PermissionManagement; |
|||
using Volo.Abp.Settings; |
|||
using Volo.Abp.Users; |
|||
|
|||
namespace LINGYUN.Platform.AspNetCore.Mvc.ApplicationConfigurations |
|||
{ |
|||
[Dependency(ServiceLifetime.Transient)] |
|||
[ExposeServices(typeof(IAbpApplicationConfigurationAppService))] |
|||
public class AbpApplicationConfigurationAppService : ApplicationService, IAbpApplicationConfigurationAppService |
|||
{ |
|||
private readonly AbpLocalizationOptions _localizationOptions; |
|||
private readonly AbpMultiTenancyOptions _multiTenancyOptions; |
|||
private readonly IServiceProvider _serviceProvider; |
|||
private readonly ISettingProvider _settingProvider; |
|||
private readonly ISettingDefinitionManager _settingDefinitionManager; |
|||
private readonly IFeatureDefinitionManager _featureDefinitionManager; |
|||
private readonly IPermissionGrantRepository _permissionGrantRepository; |
|||
private readonly IPermissionDefinitionManager _permissionDefinitionManager; |
|||
private readonly ILanguageProvider _languageProvider; |
|||
private readonly ICachedObjectExtensionsDtoService _cachedObjectExtensionsDtoService; |
|||
|
|||
private ICurrentClient _currentClient; |
|||
|
|||
protected ICurrentClient CurrentClient => LazyGetRequiredService(ref _currentClient); |
|||
|
|||
private ILocalEventBus _localEventBus; |
|||
//用于发布权限事件,每次请求此接口后,通过事件总线来缓存权限
|
|||
protected ILocalEventBus LocalEventBus => LazyGetRequiredService(ref _localEventBus); |
|||
|
|||
public AbpApplicationConfigurationAppService( |
|||
IOptions<AbpLocalizationOptions> localizationOptions, |
|||
IOptions<AbpMultiTenancyOptions> multiTenancyOptions, |
|||
IServiceProvider serviceProvider, |
|||
ISettingProvider settingProvider, |
|||
ISettingDefinitionManager settingDefinitionManager, |
|||
IFeatureDefinitionManager featureDefinitionManager, |
|||
IPermissionGrantRepository permissionGrantRepository, |
|||
IPermissionDefinitionManager permissionDefinitionManager, |
|||
ILanguageProvider languageProvider, |
|||
ICachedObjectExtensionsDtoService cachedObjectExtensionsDtoService) |
|||
{ |
|||
_serviceProvider = serviceProvider; |
|||
_settingProvider = settingProvider; |
|||
_settingDefinitionManager = settingDefinitionManager; |
|||
_featureDefinitionManager = featureDefinitionManager; |
|||
_permissionGrantRepository = permissionGrantRepository; |
|||
_permissionDefinitionManager = permissionDefinitionManager; |
|||
_languageProvider = languageProvider; |
|||
_cachedObjectExtensionsDtoService = cachedObjectExtensionsDtoService; |
|||
_localizationOptions = localizationOptions.Value; |
|||
_multiTenancyOptions = multiTenancyOptions.Value; |
|||
} |
|||
|
|||
public virtual async Task<ApplicationConfigurationDto> GetAsync() |
|||
{ |
|||
//TODO: Optimize & cache..?
|
|||
|
|||
Logger.LogDebug("Executing AbpApplicationConfigurationAppService.GetAsync()..."); |
|||
|
|||
var result = new ApplicationConfigurationDto |
|||
{ |
|||
Auth = await GetAuthConfigAsync(), |
|||
Features = await GetFeaturesConfigAsync(), |
|||
Localization = await GetLocalizationConfigAsync(), |
|||
CurrentUser = GetCurrentUser(), |
|||
Setting = await GetSettingConfigAsync(), |
|||
MultiTenancy = GetMultiTenancy(), |
|||
CurrentTenant = GetCurrentTenant(), |
|||
ObjectExtensions = _cachedObjectExtensionsDtoService.Get() |
|||
}; |
|||
|
|||
Logger.LogDebug("Executed AbpApplicationConfigurationAppService.GetAsync()."); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
protected virtual CurrentTenantDto GetCurrentTenant() |
|||
{ |
|||
return new CurrentTenantDto() |
|||
{ |
|||
Id = CurrentTenant.Id, |
|||
Name = CurrentTenant.Name, |
|||
IsAvailable = CurrentTenant.IsAvailable |
|||
}; |
|||
} |
|||
|
|||
protected virtual MultiTenancyInfoDto GetMultiTenancy() |
|||
{ |
|||
return new MultiTenancyInfoDto |
|||
{ |
|||
IsEnabled = _multiTenancyOptions.IsEnabled |
|||
}; |
|||
} |
|||
|
|||
protected virtual CurrentUserDto GetCurrentUser() |
|||
{ |
|||
return new CurrentUserDto |
|||
{ |
|||
IsAuthenticated = CurrentUser.IsAuthenticated, |
|||
Id = CurrentUser.Id, |
|||
TenantId = CurrentUser.TenantId, |
|||
UserName = CurrentUser.UserName, |
|||
Email = CurrentUser.Email |
|||
}; |
|||
} |
|||
|
|||
protected virtual async Task<ApplicationAuthConfigurationDto> GetAuthConfigAsync() |
|||
{ |
|||
var authConfig = new ApplicationAuthConfigurationDto(); |
|||
|
|||
var permissions = _permissionDefinitionManager.GetPermissions(); |
|||
|
|||
IEnumerable<PermissionGrant> grantPermissions = new List<PermissionGrant>(); |
|||
|
|||
// TODO: 重写为每次调用接口都在数据库统一查询权限
|
|||
// 待框架改进权限Provider机制后再移除
|
|||
|
|||
// 如果用户已登录,获取用户和角色权限
|
|||
if (CurrentUser.IsAuthenticated) |
|||
{ |
|||
var userPermissions = await _permissionGrantRepository.GetListAsync(UserPermissionValueProvider.ProviderName, |
|||
CurrentUser.GetId().ToString()); |
|||
grantPermissions = grantPermissions.Union(userPermissions); |
|||
foreach(var userRole in CurrentUser.Roles) |
|||
{ |
|||
var rolePermissions = await _permissionGrantRepository.GetListAsync(RolePermissionValueProvider.ProviderName, |
|||
userRole); |
|||
grantPermissions = grantPermissions.Union(rolePermissions); |
|||
} |
|||
} |
|||
|
|||
// 如果客户端已验证,获取客户端权限
|
|||
if(CurrentClient.IsAuthenticated) |
|||
{ |
|||
var clientPermissions = await _permissionGrantRepository.GetListAsync(ClientPermissionValueProvider.ProviderName, |
|||
CurrentClient.Id); |
|||
grantPermissions = grantPermissions.Union(clientPermissions); |
|||
} |
|||
|
|||
foreach(var permission in permissions) |
|||
{ |
|||
authConfig.Policies[permission.Name] = true; |
|||
if(grantPermissions.Any(p => p.Name.Equals(permission.Name))) |
|||
{ |
|||
authConfig.GrantedPolicies[permission.Name] = true; |
|||
} |
|||
} |
|||
|
|||
return authConfig; |
|||
} |
|||
|
|||
protected virtual async Task<ApplicationLocalizationConfigurationDto> GetLocalizationConfigAsync() |
|||
{ |
|||
var localizationConfig = new ApplicationLocalizationConfigurationDto(); |
|||
|
|||
localizationConfig.Languages.AddRange(await _languageProvider.GetLanguagesAsync()); |
|||
|
|||
foreach (var resource in _localizationOptions.Resources.Values) |
|||
{ |
|||
var dictionary = new Dictionary<string, string>(); |
|||
|
|||
var localizer = _serviceProvider.GetRequiredService( |
|||
typeof(IStringLocalizer<>).MakeGenericType(resource.ResourceType) |
|||
) as IStringLocalizer; |
|||
|
|||
foreach (var localizedString in localizer.GetAllStrings()) |
|||
{ |
|||
dictionary[localizedString.Name] = localizedString.Value; |
|||
} |
|||
|
|||
localizationConfig.Values[resource.ResourceName] = dictionary; |
|||
} |
|||
|
|||
localizationConfig.CurrentCulture = GetCurrentCultureInfo(); |
|||
|
|||
if (_localizationOptions.DefaultResourceType != null) |
|||
{ |
|||
localizationConfig.DefaultResourceName = LocalizationResourceNameAttribute.GetName( |
|||
_localizationOptions.DefaultResourceType |
|||
); |
|||
} |
|||
|
|||
return localizationConfig; |
|||
} |
|||
|
|||
private static CurrentCultureDto GetCurrentCultureInfo() |
|||
{ |
|||
return new CurrentCultureDto |
|||
{ |
|||
Name = CultureInfo.CurrentUICulture.Name, |
|||
DisplayName = CultureInfo.CurrentUICulture.DisplayName, |
|||
EnglishName = CultureInfo.CurrentUICulture.EnglishName, |
|||
NativeName = CultureInfo.CurrentUICulture.NativeName, |
|||
IsRightToLeft = CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft, |
|||
CultureName = CultureInfo.CurrentUICulture.TextInfo.CultureName, |
|||
TwoLetterIsoLanguageName = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName, |
|||
ThreeLetterIsoLanguageName = CultureInfo.CurrentUICulture.ThreeLetterISOLanguageName, |
|||
DateTimeFormat = new DateTimeFormatDto |
|||
{ |
|||
CalendarAlgorithmType = CultureInfo.CurrentUICulture.DateTimeFormat.Calendar.AlgorithmType.ToString(), |
|||
DateTimeFormatLong = CultureInfo.CurrentUICulture.DateTimeFormat.LongDatePattern, |
|||
ShortDatePattern = CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern, |
|||
FullDateTimePattern = CultureInfo.CurrentUICulture.DateTimeFormat.FullDateTimePattern, |
|||
DateSeparator = CultureInfo.CurrentUICulture.DateTimeFormat.DateSeparator, |
|||
ShortTimePattern = CultureInfo.CurrentUICulture.DateTimeFormat.ShortTimePattern, |
|||
LongTimePattern = CultureInfo.CurrentUICulture.DateTimeFormat.LongTimePattern, |
|||
} |
|||
}; |
|||
} |
|||
|
|||
private async Task<ApplicationSettingConfigurationDto> GetSettingConfigAsync() |
|||
{ |
|||
var result = new ApplicationSettingConfigurationDto |
|||
{ |
|||
Values = new Dictionary<string, string>() |
|||
}; |
|||
|
|||
foreach (var settingDefinition in _settingDefinitionManager.GetAll()) |
|||
{ |
|||
if (!settingDefinition.IsVisibleToClients) |
|||
{ |
|||
continue; |
|||
} |
|||
|
|||
result.Values[settingDefinition.Name] = await _settingProvider.GetOrNullAsync(settingDefinition.Name); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
protected virtual async Task<ApplicationFeatureConfigurationDto> GetFeaturesConfigAsync() |
|||
{ |
|||
var result = new ApplicationFeatureConfigurationDto(); |
|||
|
|||
foreach (var featureDefinition in _featureDefinitionManager.GetAll()) |
|||
{ |
|||
if (!featureDefinition.IsVisibleToClients) |
|||
{ |
|||
continue; |
|||
} |
|||
|
|||
result.Values[featureDefinition.Name] = await FeatureChecker.GetOrNullAsync(featureDefinition.Name); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
{ |
|||
"culture": "en", |
|||
"texts": { |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
{ |
|||
"culture": "zh-Hans", |
|||
"texts": { |
|||
"DisplayName:Abp.Identity.SignIn.EnablePhoneNumberConfirmation": "启用电话号码确认", |
|||
"Description:Abp.Identity.SignIn.EnablePhoneNumberConfirmation": "用户是否可以确认电话号码." |
|||
} |
|||
} |
|||
@ -1,38 +1,27 @@ |
|||
import { AbpConfiguration } from '@/api/abpconfiguration' |
|||
const abpConfigKey = 'vue_admin_abp_configuration' |
|||
export const getAbpConfig = () => { |
|||
const abpConfigItem = localStorage.getItem(abpConfigKey) |
|||
if (abpConfigItem) { |
|||
return JSON.parse(abpConfigItem) as AbpConfiguration |
|||
export function getItem(key: string) { |
|||
const item = localStorage.getItem(key) |
|||
if (item) { |
|||
return item |
|||
} |
|||
return new AbpConfiguration() |
|||
} |
|||
export const setAbpConfig = (abpConfig: AbpConfiguration) => { |
|||
const abpConfigItem = JSON.stringify(abpConfig) |
|||
localStorage.setItem(abpConfigKey, abpConfigItem) |
|||
return '' |
|||
} |
|||
export const removeAbpConfig = () => localStorage.removeItem(abpConfigKey) |
|||
|
|||
// User
|
|||
const tokenKey = 'vue_typescript_admin_token' |
|||
const refreshTokenKey = 'vue_typescript_admin_refresh_token' |
|||
export function getToken() { |
|||
const tokenItem = localStorage.getItem(tokenKey) |
|||
if (tokenItem) { |
|||
return tokenItem |
|||
export function getItemJson(key: string) { |
|||
const item = localStorage.getItem(key) |
|||
if (item) { |
|||
return JSON.parse(item) |
|||
} |
|||
return '' |
|||
return null |
|||
} |
|||
export const setToken = (token: string) => localStorage.setItem(tokenKey, token) |
|||
export const getRefreshToken = () => { |
|||
const tokenItem = localStorage.getItem(refreshTokenKey) |
|||
if (tokenItem) { |
|||
return tokenItem |
|||
} |
|||
return '' |
|||
|
|||
export function setItem(key: string, value: string) { |
|||
localStorage.setItem(key, value) |
|||
} |
|||
|
|||
export function removeItem(key: string) { |
|||
localStorage.removeItem(key) |
|||
} |
|||
|
|||
export function clear() { |
|||
localStorage.clear() |
|||
} |
|||
export const setRefreshToken = (token: string) => localStorage.setItem(refreshTokenKey, token) |
|||
export const removeToken = () => { |
|||
localStorage.removeItem(tokenKey) |
|||
localStorage.removeItem(refreshTokenKey) |
|||
} |
|||
@ -0,0 +1,277 @@ |
|||
<template> |
|||
<div v-if="globalSettingLoaded"> |
|||
<el-form |
|||
v-if="globalSettingLoaded" |
|||
ref="formGlobalSetting" |
|||
v-model="globalSetting" |
|||
label-width="180px" |
|||
style="width: 96%" |
|||
> |
|||
<el-tabs> |
|||
<el-tab-pane :label="$t('settings.systemSetting')"> |
|||
<el-form-item |
|||
prop="globalSetting['Abp.Localization.DefaultLanguage'].value" |
|||
:label="globalSetting['Abp.Localization.DefaultLanguage'].displayName" |
|||
> |
|||
<el-input |
|||
v-model="globalSetting['Abp.Localization.DefaultLanguage'].value" |
|||
:placeholder="globalSetting['Abp.Localization.DefaultLanguage'].description" |
|||
@input="(value) => handleSettingValueChanged('Abp.Localization.DefaultLanguage', value)" |
|||
/> |
|||
</el-form-item> |
|||
</el-tab-pane> |
|||
<el-tab-pane |
|||
v-if="allowIdentitySetting" |
|||
:label="$t('settings.passwordSecurity')" |
|||
> |
|||
<el-form-item :label="globalSetting['Abp.Identity.Password.RequiredLength'].displayName"> |
|||
<el-input |
|||
v-model="globalSetting['Abp.Identity.Password.RequiredLength'].value" |
|||
:placeholder="globalSetting['Abp.Identity.Password.RequiredLength'].description" |
|||
type="number" |
|||
@input="(value) => handleSettingValueChanged('Abp.Identity.Password.RequiredLength', value)" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item :label="globalSetting['Abp.Identity.Password.RequiredUniqueChars'].displayName"> |
|||
<el-input |
|||
v-model="globalSetting['Abp.Identity.Password.RequiredUniqueChars'].value" |
|||
type="number" |
|||
@input="(value) => handleSettingValueChanged('Abp.Identity.Password.RequiredUniqueChars', value)" |
|||
/> |
|||
</el-form-item> |
|||
<el-row> |
|||
<el-col :span="8"> |
|||
<el-form-item :label="globalSetting['Abp.Identity.Password.RequireNonAlphanumeric'].displayName"> |
|||
<el-switch |
|||
v-model="globalSetting['Abp.Identity.Password.RequireNonAlphanumeric'].value" |
|||
@input="(value) => handleSettingValueChanged('Abp.Identity.Password.RequireNonAlphanumeric', value)" |
|||
/> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="8"> |
|||
<el-form-item :label="globalSetting['Abp.Identity.Password.RequireLowercase'].displayName"> |
|||
<el-switch |
|||
v-model="globalSetting['Abp.Identity.Password.RequireLowercase'].value" |
|||
@input="(value) => handleSettingValueChanged('Abp.Identity.Password.RequireLowercase', value)" |
|||
/> |
|||
</el-form-item> |
|||
</el-col> |
|||
</el-row> |
|||
<el-row> |
|||
<el-col :span="8"> |
|||
<el-form-item :label="globalSetting['Abp.Identity.Password.RequireUppercase'].displayName"> |
|||
<el-switch |
|||
v-model="globalSetting['Abp.Identity.Password.RequireUppercase'].value" |
|||
@input="(value) => handleSettingValueChanged('Abp.Identity.Password.RequireUppercase', value)" |
|||
/> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="8"> |
|||
<el-form-item :label="globalSetting['Abp.Identity.Password.RequireDigit'].displayName"> |
|||
<el-switch |
|||
v-model="globalSetting['Abp.Identity.Password.RequireDigit'].value" |
|||
@input="(value) => handleSettingValueChanged('Abp.Identity.Password.RequireDigit', value)" |
|||
/> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-form-item :label="globalSetting['Abp.Identity.Lockout.AllowedForNewUsers'].displayName"> |
|||
<el-switch |
|||
v-model="globalSetting['Abp.Identity.Lockout.AllowedForNewUsers'].value" |
|||
@input="(value) => handleSettingValueChanged('Abp.Identity.Lockout.AllowedForNewUsers', value)" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item :label="globalSetting['Abp.Identity.Lockout.MaxFailedAccessAttempts'].displayName"> |
|||
<el-input |
|||
v-model="globalSetting['Abp.Identity.Lockout.MaxFailedAccessAttempts'].value" |
|||
:placeholder="globalSetting['Abp.Identity.Lockout.MaxFailedAccessAttempts'].description" |
|||
type="number" |
|||
@input="(value) => handleSettingValueChanged('Abp.Identity.Lockout.MaxFailedAccessAttempts', value)" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item :label="globalSetting['Abp.Identity.Lockout.LockoutDuration'].displayName"> |
|||
<el-input |
|||
v-model="globalSetting['Abp.Identity.Lockout.LockoutDuration'].value" |
|||
:placeholder="globalSetting['Abp.Identity.Lockout.LockoutDuration'].description" |
|||
type="number" |
|||
@input="(value) => handleSettingValueChanged('Abp.Identity.Lockout.LockoutDuration', value)" |
|||
/> |
|||
</el-form-item> |
|||
</el-row> |
|||
</el-tab-pane> |
|||
<el-tab-pane |
|||
v-if="allowAccountSetting" |
|||
:label="$t('settings.userAccount')" |
|||
> |
|||
<el-row> |
|||
<el-col :span="8"> |
|||
<el-form-item :label="globalSetting['Abp.Identity.SignIn.RequireConfirmedEmail'].displayName"> |
|||
<el-switch |
|||
v-model="globalSetting['Abp.Identity.SignIn.RequireConfirmedEmail'].value" |
|||
@input="(value) => handleSettingValueChanged('Abp.Identity.SignIn.RequireConfirmedEmail', value)" |
|||
/> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="8"> |
|||
<el-form-item :label="globalSetting['Abp.Identity.SignIn.EnablePhoneNumberConfirmation'].displayName"> |
|||
<el-switch |
|||
v-model="globalSetting['Abp.Identity.SignIn.EnablePhoneNumberConfirmation'].value" |
|||
@input="(value) => handleSettingValueChanged('Abp.Identity.SignIn.EnablePhoneNumberConfirmation', value)" |
|||
/> |
|||
</el-form-item> |
|||
</el-col> |
|||
</el-row> |
|||
<el-row> |
|||
<el-col :span="8"> |
|||
<el-form-item :label="globalSetting['Abp.Identity.SignIn.RequireConfirmedPhoneNumber'].displayName"> |
|||
<el-switch |
|||
v-model="globalSetting['Abp.Identity.SignIn.RequireConfirmedPhoneNumber'].value" |
|||
@input="(value) => handleSettingValueChanged('Abp.Identity.SignIn.RequireConfirmedPhoneNumber', value)" |
|||
/> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="8"> |
|||
<el-form-item :label="globalSetting['Abp.Identity.User.IsUserNameUpdateEnabled'].displayName"> |
|||
<el-switch |
|||
v-model="globalSetting['Abp.Identity.User.IsUserNameUpdateEnabled'].value" |
|||
@input="(value) => handleSettingValueChanged('Abp.Identity.User.IsUserNameUpdateEnabled', value)" |
|||
/> |
|||
</el-form-item> |
|||
</el-col> |
|||
</el-row> |
|||
<el-form-item :label="globalSetting['Abp.Identity.User.IsEmailUpdateEnabled'].displayName"> |
|||
<el-switch |
|||
v-model="globalSetting['Abp.Identity.User.IsEmailUpdateEnabled'].value" |
|||
@input="(value) => handleSettingValueChanged('Abp.Identity.User.IsEmailUpdateEnabled', value)" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item :label="globalSetting['Abp.Account.SmsRegisterTemplateCode'].displayName"> |
|||
<el-input |
|||
v-model="globalSetting['Abp.Account.SmsRegisterTemplateCode'].value" |
|||
:placeholder="globalSetting['Abp.Account.SmsRegisterTemplateCode'].description" |
|||
@input="(value) => handleSettingValueChanged('Abp.Account.SmsRegisterTemplateCode', value)" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item :label="globalSetting['Abp.Account.SmsSigninTemplateCode'].displayName"> |
|||
<el-input |
|||
v-model="globalSetting['Abp.Account.SmsSigninTemplateCode'].value" |
|||
:placeholder="globalSetting['Abp.Account.SmsSigninTemplateCode'].description" |
|||
@input="(value) => handleSettingValueChanged('Abp.Account.SmsSigninTemplateCode', value)" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item :label="globalSetting['Abp.Account.PhoneVerifyCodeExpiration'].displayName"> |
|||
<el-input |
|||
v-model="globalSetting['Abp.Account.PhoneVerifyCodeExpiration'].value" |
|||
:placeholder="globalSetting['Abp.Account.PhoneVerifyCodeExpiration'].description" |
|||
@input="(value) => handleSettingValueChanged('Abp.Account.PhoneVerifyCodeExpiration', value)" |
|||
/> |
|||
</el-form-item> |
|||
<el-row> |
|||
<el-col :span="8"> |
|||
<el-form-item :label="globalSetting['Abp.Account.IsSelfRegistrationEnabled'].displayName"> |
|||
<el-switch |
|||
v-model="globalSetting['Abp.Account.IsSelfRegistrationEnabled'].value" |
|||
@input="(value) => handleSettingValueChanged('Abp.Account.IsSelfRegistrationEnabled', value)" |
|||
/> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="12"> |
|||
<el-form-item :label="globalSetting['Abp.Account.EnableLocalLogin'].displayName"> |
|||
<el-switch |
|||
v-model="globalSetting['Abp.Account.EnableLocalLogin'].value" |
|||
@input="(value) => handleSettingValueChanged('Abp.Account.EnableLocalLogin', value)" |
|||
/> |
|||
</el-form-item> |
|||
</el-col> |
|||
</el-row> |
|||
</el-tab-pane> |
|||
</el-tabs> |
|||
|
|||
<el-form-item> |
|||
<el-button |
|||
type="primary" |
|||
style="width:200px;margin:inherit;" |
|||
@click="onSaveGlobalSetting" |
|||
> |
|||
{{ $t('global.confirm') }} |
|||
</el-button> |
|||
</el-form-item> |
|||
</el-form> |
|||
</div> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import { Component, Vue } from 'vue-property-decorator' |
|||
import SettingService, { Setting, SettingUpdate, SettingsUpdate } from '@/api/settings' |
|||
|
|||
const booleanStrings = ['True', 'true', 'False', 'false'] |
|||
|
|||
@Component({ |
|||
name: 'GlobalSettingEditForm' |
|||
}) |
|||
export default class extends Vue { |
|||
private globalSettingLoaded = false |
|||
private globalSetting: {[key: string]: Setting} = {} |
|||
private globalSettingChangeKeys = new Array<string>() |
|||
|
|||
get allowIdentitySetting() { |
|||
if (this.globalSetting['Abp.Identity.Password.RequiredLength']) { |
|||
return true |
|||
} |
|||
return false |
|||
} |
|||
|
|||
get allowAccountSetting() { |
|||
if (this.globalSetting['Abp.Account.EnableLocalLogin']) { |
|||
return true |
|||
} |
|||
return false |
|||
} |
|||
|
|||
mounted() { |
|||
this.handleGetGlobalSettings() |
|||
} |
|||
|
|||
private handleSettingValueChanged(key: string, value: any) { |
|||
if (!this.globalSettingChangeKeys.includes(key)) { |
|||
this.globalSettingChangeKeys.push(key) |
|||
} |
|||
this.$set(this.globalSetting[key], 'value', value) |
|||
this.$forceUpdate() |
|||
} |
|||
|
|||
private handleGetGlobalSettings() { |
|||
SettingService.getSettings('G', '').then(settings => { |
|||
settings.items.forEach(setting => { |
|||
if (setting.value) { |
|||
const value = setting.value.toLowerCase() |
|||
if (booleanStrings.includes(value)) { |
|||
setting.value = value === 'true' |
|||
} |
|||
} else { |
|||
const defaultValue = setting.defaultValue.toLowerCase() |
|||
if (booleanStrings.includes(defaultValue)) { |
|||
setting.value = defaultValue === 'true' |
|||
} |
|||
} |
|||
this.globalSetting[setting.name] = setting |
|||
}) |
|||
this.globalSettingLoaded = true |
|||
}) |
|||
} |
|||
|
|||
private onSaveGlobalSetting() { |
|||
const updateSettings = new SettingsUpdate() |
|||
this.globalSettingChangeKeys.forEach(key => { |
|||
const updateSetting = new SettingUpdate() |
|||
updateSetting.name = key |
|||
updateSetting.value = this.globalSetting[key].value |
|||
updateSettings.settings.push(updateSetting) |
|||
}) |
|||
if (updateSettings.settings.length > 0) { |
|||
SettingService.setSettings('G', '', updateSettings).then(() => { |
|||
this.$message.success(this.$t('AbpSettingManagement.SuccessfullySaved').toString()) |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
Loading…
Reference in new issue