From 729c2e24de91b5070c1597ada0a6c91ef1b2c81a Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Sun, 24 May 2020 15:17:23 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=86=99IdentityOptions=E4=B8=B4?= =?UTF-8?q?=E6=97=B6=E8=A7=A3=E5=86=B3=E4=B8=80=E4=B8=AA=E6=A1=86=E6=9E=B6?= =?UTF-8?q?=E6=80=A7=E8=83=BD=E5=BD=B1=E5=93=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...N.Abp.Account.Application.Contracts.csproj | 10 -- .../AbpAccountApplicationContractsModule.cs | 20 +--- .../Abp/Account/Dto/RegisterVerifyDto.cs | 3 + .../Account/Localization/Resources/en.json | 8 -- .../Localization/Resources/zh-Hans.json | 8 -- .../LINGYUN/Abp/Account/AccountAppService.cs | 4 +- .../Account/Localization/Resources/en.json | 3 + .../Localization/Resources/zh-Hans.json | 3 + .../Abp/Account/AbpAccountHttpApiModule.cs | 12 ++ ...INGYUN.Abp.Identity.OverrideOptions.csproj | 12 ++ .../AbpIdentityOverrideOptionsFactory.cs | 23 ++++ .../AbpIdentityOverrideOptionsModule.cs | 37 +++++++ .../LINYUN/Abp/Sms/Aliyun/AliyunSmsOptions.cs | 2 +- .../LINYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs | 3 +- .../Volo/Abp/Sms/AliyunSmsSenderExtensions.cs | 49 +++++++++ .../AuthIdentityServerModule.cs | 6 +- .../AuthServer.Host/AuthServer.Host.csproj | 1 + .../LINGYUN.Platform.HttpApi.Host.csproj | 1 + .../PlatformHttpApiHostModule.cs | 2 + vueJs/.env.development | 1 + vueJs/src/api/users.ts | 4 + vueJs/src/permission.ts | 2 +- vueJs/src/store/modules/permission.ts | 7 +- vueJs/src/store/modules/user.ts | 21 +--- vueJs/src/views/login/index.vue | 103 +++++++++--------- 25 files changed, 224 insertions(+), 121 deletions(-) delete mode 100644 aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/en.json delete mode 100644 aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json create mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Identity.OverrideOptions/LINGYUN.Abp.Identity.OverrideOptions.csproj create mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Identity.OverrideOptions/LINGYUN/Abp/Identity/AbpIdentityOverrideOptionsFactory.cs create mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Identity.OverrideOptions/LINGYUN/Abp/Identity/AbpIdentityOverrideOptionsModule.cs create mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/Volo/Abp/Sms/AliyunSmsSenderExtensions.cs diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN.Abp.Account.Application.Contracts.csproj b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN.Abp.Account.Application.Contracts.csproj index aa212cfed..24ba91acc 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN.Abp.Account.Application.Contracts.csproj +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN.Abp.Account.Application.Contracts.csproj @@ -5,16 +5,6 @@ - - - - - - - - - - diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/AbpAccountApplicationContractsModule.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/AbpAccountApplicationContractsModule.cs index 72a42a84f..50ff26017 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/AbpAccountApplicationContractsModule.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/AbpAccountApplicationContractsModule.cs @@ -1,27 +1,9 @@ -using Volo.Abp.Account.Localization; -using Volo.Abp.Localization; -using Volo.Abp.Modularity; -using Volo.Abp.VirtualFileSystem; +using Volo.Abp.Modularity; namespace LINGYUN.Abp.Account { [DependsOn(typeof(AbpAccountDomainSharedModule))] public class AbpAccountApplicationContractsModule : AbpModule { - public override void ConfigureServices(ServiceConfigurationContext context) - { - Configure(options => - { - options.FileSets.AddEmbedded(); - }); - - Configure(options => - { - options.Resources - .Get() - .AddBaseTypes(typeof(AccountResource)) - .AddVirtualJson("/LINGYUN/Abp/Account/Localization/Resources"); - }); - } } } diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/RegisterVerifyDto.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/RegisterVerifyDto.cs index dce404f29..5de7157a2 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/RegisterVerifyDto.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/RegisterVerifyDto.cs @@ -11,6 +11,9 @@ namespace LINGYUN.Abp.Account [StringLength(IdentityUserConsts.MaxPhoneNumberLength)] public string PhoneNumber { get; set; } + [StringLength(IdentityUserConsts.MaxNameLength)] + public string Name { get; set; } + [StringLength(IdentityUserConsts.MaxUserNameLength)] public string UserName { get; set; } diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/en.json b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/en.json deleted file mode 100644 index b61468521..000000000 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/en.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "culture": "en", - "texts": { - "PhoneNumberNotRegisterd": "The registered mobile phone number is not registered!", - "PhoneVerifyCodeInvalid": "The phone verification code is invalid or expired!", - "PhoneVerifyCodeNotRepeatSend": "Phone verification code cannot be sent repeatedly within {0} minutes!" - } -} \ No newline at end of file diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json deleted file mode 100644 index f054a8048..000000000 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "culture": "zh-Hans", - "texts": { - "PhoneNumberNotRegisterd": "手机号码未注册!", - "PhoneVerifyCodeInvalid": "手机验证码无效或已经过期!", - "PhoneVerifyCodeNotRepeatSend": "手机验证码不能在 {0} 分钟内重复发送!" - } -} \ No newline at end of file diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountAppService.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountAppService.cs index 7a824cb11..c2e5e7982 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountAppService.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountAppService.cs @@ -60,10 +60,10 @@ namespace LINGYUN.Abp.Account var userEmail = input.EmailAddress ?? input.PhoneNumber + "@abp.io"; var userName = input.UserName ?? input.PhoneNumber; var user = new IdentityUser(GuidGenerator.Create(), userName, userEmail, CurrentTenant.Id); - + user.Name = input.Name ?? input.PhoneNumber; (await UserManager.CreateAsync(user, input.Password)).CheckErrors(); - await UserManager.SetPhoneNumberAsync(user, input.PhoneNumber); + await UserManager.ChangePhoneNumberAsync(user, input.PhoneNumber, input.VerifyCode); await UserManager.SetEmailAsync(user, userEmail); await UserManager.AddDefaultRolesAsync(user); diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/Localization/Resources/en.json b/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/Localization/Resources/en.json index b49a3d2b8..488ddc52f 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/Localization/Resources/en.json +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/Localization/Resources/en.json @@ -1,6 +1,9 @@ { "culture": "en", "texts": { + "PhoneNumberNotRegisterd": "The registered mobile phone number is not registered!", + "PhoneVerifyCodeInvalid": "The phone verification code is invalid or expired!", + "PhoneVerifyCodeNotRepeatSend": "Phone verification code cannot be sent repeatedly within {0} minutes!", "DisplayName:SmsRegisterTemplateCode": "Register sms template", "Description:SmsRegisterTemplateCode": "When the user registers, he/she should send the template number of the SMS verification code and fill in the template number of the corresponding cloud platform registration", "DisplayName:SmsSigninTemplateCode": "Signin sms template", diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json b/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json index c7a2c1df6..479cf69fa 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json @@ -1,6 +1,9 @@ { "culture": "zh-Hans", "texts": { + "PhoneNumberNotRegisterd": "手机号码未注册!", + "PhoneVerifyCodeInvalid": "手机验证码无效或已经过期!", + "PhoneVerifyCodeNotRepeatSend": "手机验证码不能在 {0} 分钟内重复发送!", "DisplayName:SmsRegisterTemplateCode": "用户注册短信模板", "Description:SmsRegisterTemplateCode": "用户注册时发送短信验证码的模板号,填写对应云平台注册的模板号", "DisplayName:SmsSigninTemplateCode": "用户登录短信模板", diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.HttpApi/LINGYUN/Abp/Account/AbpAccountHttpApiModule.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.HttpApi/LINGYUN/Abp/Account/AbpAccountHttpApiModule.cs index fb49e8866..9ed5a4bc3 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.HttpApi/LINGYUN/Abp/Account/AbpAccountHttpApiModule.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.HttpApi/LINGYUN/Abp/Account/AbpAccountHttpApiModule.cs @@ -1,5 +1,7 @@ using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Account.Localization; using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Localization; using Volo.Abp.Modularity; namespace LINGYUN.Abp.Account @@ -16,5 +18,15 @@ namespace LINGYUN.Abp.Account mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpAccountHttpApiModule).Assembly); }); } + + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.Resources + .Get() + .AddBaseTypes(typeof(AccountResource)); + }); + } } } diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Identity.OverrideOptions/LINGYUN.Abp.Identity.OverrideOptions.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Identity.OverrideOptions/LINGYUN.Abp.Identity.OverrideOptions.csproj new file mode 100644 index 000000000..5260b1752 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Identity.OverrideOptions/LINGYUN.Abp.Identity.OverrideOptions.csproj @@ -0,0 +1,12 @@ + + + + netstandard2.0 + + + + + + + + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Identity.OverrideOptions/LINGYUN/Abp/Identity/AbpIdentityOverrideOptionsFactory.cs b/aspnet-core/modules/common/LINGYUN.Abp.Identity.OverrideOptions/LINGYUN/Abp/Identity/AbpIdentityOverrideOptionsFactory.cs new file mode 100644 index 000000000..c7cefecfd --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Identity.OverrideOptions/LINGYUN/Abp/Identity/AbpIdentityOverrideOptionsFactory.cs @@ -0,0 +1,23 @@ +using Microsoft.AspNetCore.Identity; +using Microsoft.Extensions.Options; +using System.Collections.Generic; +using Volo.Abp.Options; + +namespace LINGYUN.Abp.Identity +{ + public class AbpIdentityOverrideOptionsFactory : AbpOptionsFactory + { + public AbpIdentityOverrideOptionsFactory( + IEnumerable> setups, + IEnumerable> postConfigures) + : base(setups, postConfigures) + { + + } + + public override IdentityOptions Create(string name) + { + return base.Create(name); + } + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Identity.OverrideOptions/LINGYUN/Abp/Identity/AbpIdentityOverrideOptionsModule.cs b/aspnet-core/modules/common/LINGYUN.Abp.Identity.OverrideOptions/LINGYUN/Abp/Identity/AbpIdentityOverrideOptionsModule.cs new file mode 100644 index 000000000..798c469a2 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Identity.OverrideOptions/LINGYUN/Abp/Identity/AbpIdentityOverrideOptionsModule.cs @@ -0,0 +1,37 @@ +using Microsoft.AspNetCore.Identity; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Options; +using System; +using Volo.Abp.Identity; +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.Identity +{ + /// + /// 重写IdentityOptions,主要替换配置工厂组件,不再从SettingProvider获取IdentityOptions配置 + /// 在跨服务器时,从SettingProvider获取配置,用户需等待很长的时间,严重影响体验 + /// 如果是本地服务器,可以忽略这些性能影响,不需要引用此模块 + /// + [DependsOn(typeof(AbpIdentityDomainModule))] + public class AbpIdentityOverrideOptionsModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + // TODO:配置文件指定IdentityOptions,避免从数据库读取的超长时间等待 + // 问题点:https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityOptionsFactory.cs + // 有11个同步等待任务去获取身份认证配置,如果缓存不存在,会执行11条数据库指令 + // 运行过程中严重影响体验 + context.Services.Replace(ServiceDescriptor.Transient, AbpIdentityOverrideOptionsFactory>()); + context.Services.Replace(ServiceDescriptor.Transient, OptionsManager>()); + + var configuration = context.Services.GetConfiguration(); + Configure(configuration.GetSection("Identity")); + Configure(options => + { + options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromSeconds(configuration.GetSection("Identity:Lockout:LockoutDuration").Get()); + }); + } + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsOptions.cs b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsOptions.cs index e4abc6eaa..3384f9982 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsOptions.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsOptions.cs @@ -25,7 +25,7 @@ /// /// 默认版本号 /// - public string DefaultVersion { get; set; } = "2017-05-25"; + public string Version { get; set; } = "2017-05-25"; /// /// 默认签名 /// diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs index 84a58c51f..0a3ef9982 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs @@ -13,7 +13,6 @@ using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.DependencyInjection; using Volo.Abp.Json; -using Volo.Abp.Localization; using Volo.Abp.Sms; namespace LINYUN.Abp.Sms.Aliyun @@ -45,7 +44,7 @@ namespace LINYUN.Abp.Sms.Aliyun Method = MethodType.POST, Domain = Options.Domain, Action = Options.ActionName, - Version = Options.DefaultVersion + Version = Options.Version }; TryAddTemplateCode(request, smsMessage); TryAddSignName(request, smsMessage); diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/Volo/Abp/Sms/AliyunSmsSenderExtensions.cs b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/Volo/Abp/Sms/AliyunSmsSenderExtensions.cs new file mode 100644 index 000000000..c2aefd8da --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/Volo/Abp/Sms/AliyunSmsSenderExtensions.cs @@ -0,0 +1,49 @@ +using LINYUN.Abp.Sms.Aliyun; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Volo.Abp.Sms +{ + public static class AliyunSmsSenderExtensions + { + /// + /// 扩展短信接口 + /// + /// + /// 短信模板号 + /// 发送手机号 + /// 短信模板参数 + /// + public static async Task SendAsync(this ISmsSender smsSender, string templateCode, string phoneNumber, IDictionary templateParams = null) + { + var smsMessage = new SmsMessage(phoneNumber, nameof(AliyunSmsSender)); + smsMessage.Properties.Add("TemplateCode", templateCode); + if(templateParams != null) + { + smsMessage.Properties.AddIfNotContains(templateParams); + } + await smsSender.SendAsync(smsMessage); + } + + /// + /// 扩展短信接口 + /// + /// + /// 短信签名 + /// 短信模板号 + /// 发送手机号 + /// 短信模板参数 + /// + public static async Task SendAsync(this ISmsSender smsSender, string signName, string templateCode, string phoneNumber, IDictionary templateParams = null) + { + var smsMessage = new SmsMessage(phoneNumber, nameof(AliyunSmsSender)); + smsMessage.Properties.Add("SignName", signName); + smsMessage.Properties.Add("TemplateCode", templateCode); + if (templateParams != null) + { + smsMessage.Properties.AddIfNotContains(templateParams); + } + await smsSender.SendAsync(smsMessage); + } + } +} diff --git a/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs b/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs index ab1d453a3..2e9890ec2 100644 --- a/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs +++ b/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs @@ -1,13 +1,16 @@ using DotNetCore.CAP; using LINGYUN.Abp.EventBus.CAP; +using LINGYUN.Abp.Identity; using LINGYUN.Abp.IdentityServer; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Options; using StackExchange.Redis; using System; using System.Linq; @@ -42,7 +45,8 @@ namespace AuthServer.Host typeof(AbpIdentityServerEntityFrameworkCoreModule), typeof(AbpSettingManagementEntityFrameworkCoreModule), typeof(AbpTenantManagementEntityFrameworkCoreModule), - typeof(AbpPermissionManagementEntityFrameworkCoreModule) + typeof(AbpPermissionManagementEntityFrameworkCoreModule), + typeof(AbpIdentityOverrideOptionsModule) )] public class AuthIdentityServerModule : AbpModule { diff --git a/aspnet-core/services/account/AuthServer.Host/AuthServer.Host.csproj b/aspnet-core/services/account/AuthServer.Host/AuthServer.Host.csproj index a938bac49..c23a9923f 100644 --- a/aspnet-core/services/account/AuthServer.Host/AuthServer.Host.csproj +++ b/aspnet-core/services/account/AuthServer.Host/AuthServer.Host.csproj @@ -33,6 +33,7 @@ + diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj index 61d1a2047..1cda942b4 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj @@ -45,6 +45,7 @@ + diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/PlatformHttpApiHostModule.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/PlatformHttpApiHostModule.cs index 02fa0c688..0cd0722c6 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/PlatformHttpApiHostModule.cs +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/PlatformHttpApiHostModule.cs @@ -1,6 +1,7 @@ using DotNetCore.CAP; using IdentityModel; using LINGYUN.Abp.EventBus.CAP; +using LINGYUN.Abp.Identity; using LINGYUN.Abp.IdentityServer; using LINGYUN.Abp.SettingManagement; using LINGYUN.Abp.TenantManagement; @@ -70,6 +71,7 @@ namespace LINGYUN.Platform typeof(AbpAspNetCoreAuthenticationJwtBearerModule), typeof(AbpCAPEventBusModule), typeof(AbpAliyunSmsModule), + typeof(AbpIdentityOverrideOptionsModule), typeof(AbpAutofacModule) )] public class PlatformHttpApiHostModule : AbpModule diff --git a/vueJs/.env.development b/vueJs/.env.development index 10d4dd314..00f064f35 100644 --- a/vueJs/.env.development +++ b/vueJs/.env.development @@ -8,6 +8,7 @@ VUE_APP_BASE_IDENTITY_SERVICE = '/api/identity' VUE_APP_BASE_IDENTITY_SERVER = '/connect' +VUE_APP_TENANT_NAME = '' VUE_APP_CLIENT_ID = 'vue-admin-element' VUE_APP_CLIENT_SECRET = '1q2w3e*' diff --git a/vueJs/src/api/users.ts b/vueJs/src/api/users.ts index 5c6442986..9444d7fe6 100644 --- a/vueJs/src/api/users.ts +++ b/vueJs/src/api/users.ts @@ -118,6 +118,10 @@ export default class UserApiService { }) } + public static refreshToken() { + + } + public static userLogout(token: string | undefined) { if (token) { const _url = '/connect/revocation' diff --git a/vueJs/src/permission.ts b/vueJs/src/permission.ts index 6f5247247..3b8038dc7 100644 --- a/vueJs/src/permission.ts +++ b/vueJs/src/permission.ts @@ -33,7 +33,7 @@ router.beforeEach(async(to: Route, _: Route, next: any) => { NProgress.done() } else { // Check whether the user has obtained his permission roles - if (PermissionModule.routes.length === 0) { + if (PermissionModule.authorizedPermissions.length === 0) { try { // Note: roles must be a object array! such as: ['admin'] or ['developer', 'editor'] const { sub } = await UserModule.GetUserInfo() diff --git a/vueJs/src/store/modules/permission.ts b/vueJs/src/store/modules/permission.ts index a3204e010..86b48568b 100644 --- a/vueJs/src/store/modules/permission.ts +++ b/vueJs/src/store/modules/permission.ts @@ -59,7 +59,12 @@ class Permission extends VuexModule implements IPermissionState { } }) }) - this.SET_AUTHPERMISSIONS(authPermissions) + if (authPermissions.length === 0) { + // 防止没有任何权限无限刷新页面 + this.SET_AUTHPERMISSIONS(['guest']) + } else { + this.SET_AUTHPERMISSIONS(authPermissions) + } } @Action diff --git a/vueJs/src/store/modules/user.ts b/vueJs/src/store/modules/user.ts index 1740838b6..e14f132ff 100644 --- a/vueJs/src/store/modules/user.ts +++ b/vueJs/src/store/modules/user.ts @@ -92,22 +92,6 @@ class User extends VuexModule implements IUserState { return userInfo } - // @Action - // public async ChangeRoles(role: string) { - // // Dynamically modify permissions - // const token = role + '-token' - // this.SET_TOKEN(token) - // setToken(token) - // await this.GetUserInfo() - // resetRouter() - // // Generate dynamic accessible routes based on roles - // // PermissionModule.GenerateRoutes(this.roles) - // // Add generated routes - // router.addRoutes(PermissionModule.dynamicRoutes) - // // Reset visited views and cached views - // TagsViewModule.delAllViews() - // } - @Action public async LogOut() { if (this.token === '') { @@ -124,6 +108,11 @@ class User extends VuexModule implements IUserState { this.SET_TOKEN('') this.SET_ROLES([]) } + + @Action + public RefreshSession() { + + } } export const UserModule = getModule(User) diff --git a/vueJs/src/views/login/index.vue b/vueJs/src/views/login/index.vue index 1176392e0..41412d078 100644 --- a/vueJs/src/views/login/index.vue +++ b/vueJs/src/views/login/index.vue @@ -28,63 +28,63 @@ tabindex="1" autocomplete="on" /> + - + + + + + + + + + - + + + + - - - - - - - - - - - - - - - {{ $t('login.logIn') }} - - + + + + {{ $t('login.logIn') }} +