Browse Source

重写IdentityOptions临时解决一个框架性能影响

pull/1/head
cKey 6 years ago
parent
commit
729c2e24de
  1. 10
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN.Abp.Account.Application.Contracts.csproj
  2. 20
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/AbpAccountApplicationContractsModule.cs
  3. 3
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/RegisterVerifyDto.cs
  4. 8
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/en.json
  5. 8
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json
  6. 4
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountAppService.cs
  7. 3
      aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/Localization/Resources/en.json
  8. 3
      aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json
  9. 12
      aspnet-core/modules/account/LINGYUN.Abp.Account.HttpApi/LINGYUN/Abp/Account/AbpAccountHttpApiModule.cs
  10. 12
      aspnet-core/modules/common/LINGYUN.Abp.Identity.OverrideOptions/LINGYUN.Abp.Identity.OverrideOptions.csproj
  11. 23
      aspnet-core/modules/common/LINGYUN.Abp.Identity.OverrideOptions/LINGYUN/Abp/Identity/AbpIdentityOverrideOptionsFactory.cs
  12. 37
      aspnet-core/modules/common/LINGYUN.Abp.Identity.OverrideOptions/LINGYUN/Abp/Identity/AbpIdentityOverrideOptionsModule.cs
  13. 2
      aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsOptions.cs
  14. 3
      aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs
  15. 49
      aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/Volo/Abp/Sms/AliyunSmsSenderExtensions.cs
  16. 6
      aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs
  17. 1
      aspnet-core/services/account/AuthServer.Host/AuthServer.Host.csproj
  18. 1
      aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj
  19. 2
      aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/PlatformHttpApiHostModule.cs
  20. 1
      vueJs/.env.development
  21. 4
      vueJs/src/api/users.ts
  22. 2
      vueJs/src/permission.ts
  23. 5
      vueJs/src/store/modules/permission.ts
  24. 21
      vueJs/src/store/modules/user.ts
  25. 5
      vueJs/src/views/login/index.vue

10
aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN.Abp.Account.Application.Contracts.csproj

@ -5,16 +5,6 @@
<RootNamespace /> <RootNamespace />
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<None Remove="LINGYUN\Abp\Account\Localization\Resources\en.json" />
<None Remove="LINGYUN\Abp\Account\Localization\Resources\zh-Hans.json" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="LINGYUN\Abp\Account\Localization\Resources\en.json" />
<EmbeddedResource Include="LINGYUN\Abp\Account\Localization\Resources\zh-Hans.json" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Volo.Abp.Account.Application.Contracts" Version="2.8.0" /> <PackageReference Include="Volo.Abp.Account.Application.Contracts" Version="2.8.0" />
</ItemGroup> </ItemGroup>

20
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.Modularity;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;
namespace LINGYUN.Abp.Account namespace LINGYUN.Abp.Account
{ {
[DependsOn(typeof(AbpAccountDomainSharedModule))] [DependsOn(typeof(AbpAccountDomainSharedModule))]
public class AbpAccountApplicationContractsModule : AbpModule public class AbpAccountApplicationContractsModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<AbpAccountApplicationContractsModule>();
});
Configure<AbpLocalizationOptions>(options =>
{
options.Resources
.Get<Localization.AccountResource>()
.AddBaseTypes(typeof(AccountResource))
.AddVirtualJson("/LINGYUN/Abp/Account/Localization/Resources");
});
}
} }
} }

3
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)] [StringLength(IdentityUserConsts.MaxPhoneNumberLength)]
public string PhoneNumber { get; set; } public string PhoneNumber { get; set; }
[StringLength(IdentityUserConsts.MaxNameLength)]
public string Name { get; set; }
[StringLength(IdentityUserConsts.MaxUserNameLength)] [StringLength(IdentityUserConsts.MaxUserNameLength)]
public string UserName { get; set; } public string UserName { get; set; }

8
aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/en.json

@ -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!"
}
}

8
aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json

@ -1,8 +0,0 @@
{
"culture": "zh-Hans",
"texts": {
"PhoneNumberNotRegisterd": "手机号码未注册!",
"PhoneVerifyCodeInvalid": "手机验证码无效或已经过期!",
"PhoneVerifyCodeNotRepeatSend": "手机验证码不能在 {0} 分钟内重复发送!"
}
}

4
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 userEmail = input.EmailAddress ?? input.PhoneNumber + "@abp.io";
var userName = input.UserName ?? input.PhoneNumber; var userName = input.UserName ?? input.PhoneNumber;
var user = new IdentityUser(GuidGenerator.Create(), userName, userEmail, CurrentTenant.Id); 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.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.SetEmailAsync(user, userEmail);
await UserManager.AddDefaultRolesAsync(user); await UserManager.AddDefaultRolesAsync(user);

3
aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/Localization/Resources/en.json

@ -1,6 +1,9 @@
{ {
"culture": "en", "culture": "en",
"texts": { "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", "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", "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", "DisplayName:SmsSigninTemplateCode": "Signin sms template",

3
aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json

@ -1,6 +1,9 @@
{ {
"culture": "zh-Hans", "culture": "zh-Hans",
"texts": { "texts": {
"PhoneNumberNotRegisterd": "手机号码未注册!",
"PhoneVerifyCodeInvalid": "手机验证码无效或已经过期!",
"PhoneVerifyCodeNotRepeatSend": "手机验证码不能在 {0} 分钟内重复发送!",
"DisplayName:SmsRegisterTemplateCode": "用户注册短信模板", "DisplayName:SmsRegisterTemplateCode": "用户注册短信模板",
"Description:SmsRegisterTemplateCode": "用户注册时发送短信验证码的模板号,填写对应云平台注册的模板号", "Description:SmsRegisterTemplateCode": "用户注册时发送短信验证码的模板号,填写对应云平台注册的模板号",
"DisplayName:SmsSigninTemplateCode": "用户登录短信模板", "DisplayName:SmsSigninTemplateCode": "用户登录短信模板",

12
aspnet-core/modules/account/LINGYUN.Abp.Account.HttpApi/LINGYUN/Abp/Account/AbpAccountHttpApiModule.cs

@ -1,5 +1,7 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Account.Localization;
using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Localization;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
namespace LINGYUN.Abp.Account namespace LINGYUN.Abp.Account
@ -16,5 +18,15 @@ namespace LINGYUN.Abp.Account
mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpAccountHttpApiModule).Assembly); mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpAccountHttpApiModule).Assembly);
}); });
} }
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpLocalizationOptions>(options =>
{
options.Resources
.Get<Localization.AccountResource>()
.AddBaseTypes(typeof(AccountResource));
});
}
} }
} }

12
aspnet-core/modules/common/LINGYUN.Abp.Identity.OverrideOptions/LINGYUN.Abp.Identity.OverrideOptions.csproj

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Identity.Domain" Version="2.8.0" />
</ItemGroup>
</Project>

23
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<IdentityOptions>
{
public AbpIdentityOverrideOptionsFactory(
IEnumerable<IConfigureOptions<IdentityOptions>> setups,
IEnumerable<IPostConfigureOptions<IdentityOptions>> postConfigures)
: base(setups, postConfigures)
{
}
public override IdentityOptions Create(string name)
{
return base.Create(name);
}
}
}

37
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
{
/// <summary>
/// 重写IdentityOptions,主要替换配置工厂组件,不再从SettingProvider获取IdentityOptions配置
/// 在跨服务器时,从SettingProvider获取配置,用户需等待很长的时间,严重影响体验
/// 如果是本地服务器,可以忽略这些性能影响,不需要引用此模块
/// </summary>
[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<IOptionsFactory<IdentityOptions>, AbpIdentityOverrideOptionsFactory>());
context.Services.Replace(ServiceDescriptor.Transient<IOptions<IdentityOptions>, OptionsManager<IdentityOptions>>());
var configuration = context.Services.GetConfiguration();
Configure<IdentityOptions>(configuration.GetSection("Identity"));
Configure<IdentityOptions>(options =>
{
options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromSeconds(configuration.GetSection("Identity:Lockout:LockoutDuration").Get<int>());
});
}
}
}

2
aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsOptions.cs

@ -25,7 +25,7 @@
/// <summary> /// <summary>
/// 默认版本号 /// 默认版本号
/// </summary> /// </summary>
public string DefaultVersion { get; set; } = "2017-05-25"; public string Version { get; set; } = "2017-05-25";
/// <summary> /// <summary>
/// 默认签名 /// 默认签名
/// </summary> /// </summary>

3
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;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Json; using Volo.Abp.Json;
using Volo.Abp.Localization;
using Volo.Abp.Sms; using Volo.Abp.Sms;
namespace LINYUN.Abp.Sms.Aliyun namespace LINYUN.Abp.Sms.Aliyun
@ -45,7 +44,7 @@ namespace LINYUN.Abp.Sms.Aliyun
Method = MethodType.POST, Method = MethodType.POST,
Domain = Options.Domain, Domain = Options.Domain,
Action = Options.ActionName, Action = Options.ActionName,
Version = Options.DefaultVersion Version = Options.Version
}; };
TryAddTemplateCode(request, smsMessage); TryAddTemplateCode(request, smsMessage);
TryAddSignName(request, smsMessage); TryAddSignName(request, smsMessage);

49
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
{
/// <summary>
/// 扩展短信接口
/// </summary>
/// <param name="smsSender"></param>
/// <param name="templateCode">短信模板号</param>
/// <param name="phoneNumber">发送手机号</param>
/// <param name="templateParams">短信模板参数</param>
/// <returns></returns>
public static async Task SendAsync(this ISmsSender smsSender, string templateCode, string phoneNumber, IDictionary<string, object> 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);
}
/// <summary>
/// 扩展短信接口
/// </summary>
/// <param name="smsSender"></param>
/// <param name="signName">短信签名</param>
/// <param name="templateCode">短信模板号</param>
/// <param name="phoneNumber">发送手机号</param>
/// <param name="templateParams">短信模板参数</param>
/// <returns></returns>
public static async Task SendAsync(this ISmsSender smsSender, string signName, string templateCode, string phoneNumber, IDictionary<string, object> 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);
}
}
}

6
aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs

@ -1,13 +1,16 @@
using DotNetCore.CAP; using DotNetCore.CAP;
using LINGYUN.Abp.EventBus.CAP; using LINGYUN.Abp.EventBus.CAP;
using LINGYUN.Abp.Identity;
using LINGYUN.Abp.IdentityServer; using LINGYUN.Abp.IdentityServer;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using StackExchange.Redis; using StackExchange.Redis;
using System; using System;
using System.Linq; using System.Linq;
@ -42,7 +45,8 @@ namespace AuthServer.Host
typeof(AbpIdentityServerEntityFrameworkCoreModule), typeof(AbpIdentityServerEntityFrameworkCoreModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule), typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(AbpTenantManagementEntityFrameworkCoreModule), typeof(AbpTenantManagementEntityFrameworkCoreModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule) typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpIdentityOverrideOptionsModule)
)] )]
public class AuthIdentityServerModule : AbpModule public class AuthIdentityServerModule : AbpModule
{ {

1
aspnet-core/services/account/AuthServer.Host/AuthServer.Host.csproj

@ -33,6 +33,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\modules\common\LINGYUN.Abp.EventBus.CAP\LINGYUN.Abp.EventBus.CAP.csproj" /> <ProjectReference Include="..\..\..\modules\common\LINGYUN.Abp.EventBus.CAP\LINGYUN.Abp.EventBus.CAP.csproj" />
<ProjectReference Include="..\..\..\modules\common\LINGYUN.Abp.Identity.OverrideOptions\LINGYUN.Abp.Identity.OverrideOptions.csproj" />
<ProjectReference Include="..\..\..\modules\common\LINGYUN.Common.EventBus\LINGYUN.Common.EventBus.csproj" /> <ProjectReference Include="..\..\..\modules\common\LINGYUN.Common.EventBus\LINGYUN.Common.EventBus.csproj" />
<ProjectReference Include="..\..\..\modules\identityServer\LINGYUN.Abp.IdentityServer.SmsValidator\LINGYUN.Abp.IdentityServer.SmsValidator.csproj" /> <ProjectReference Include="..\..\..\modules\identityServer\LINGYUN.Abp.IdentityServer.SmsValidator\LINGYUN.Abp.IdentityServer.SmsValidator.csproj" />
</ItemGroup> </ItemGroup>

1
aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj

@ -45,6 +45,7 @@
<ProjectReference Include="..\..\..\modules\account\LINGYUN.Abp.Account.HttpApi\LINGYUN.Abp.Account.HttpApi.csproj" /> <ProjectReference Include="..\..\..\modules\account\LINGYUN.Abp.Account.HttpApi\LINGYUN.Abp.Account.HttpApi.csproj" />
<ProjectReference Include="..\..\..\modules\apigateway\LINGYUN.ApiGateway.Application.Contracts\LINGYUN.ApiGateway.Application.Contracts.csproj" /> <ProjectReference Include="..\..\..\modules\apigateway\LINGYUN.ApiGateway.Application.Contracts\LINGYUN.ApiGateway.Application.Contracts.csproj" />
<ProjectReference Include="..\..\..\modules\common\LINGYUN.Abp.EventBus.CAP\LINGYUN.Abp.EventBus.CAP.csproj" /> <ProjectReference Include="..\..\..\modules\common\LINGYUN.Abp.EventBus.CAP\LINGYUN.Abp.EventBus.CAP.csproj" />
<ProjectReference Include="..\..\..\modules\common\LINGYUN.Abp.Identity.OverrideOptions\LINGYUN.Abp.Identity.OverrideOptions.csproj" />
<ProjectReference Include="..\..\..\modules\common\LINGYUN.Abp.Sms.Aliyun\LINGYUN.Abp.Sms.Aliyun.csproj" /> <ProjectReference Include="..\..\..\modules\common\LINGYUN.Abp.Sms.Aliyun\LINGYUN.Abp.Sms.Aliyun.csproj" />
<ProjectReference Include="..\..\..\modules\identityServer\LINGYUN.Abp.IdentityServer.Application\LINGYUN.Abp.IdentityServer.Application.csproj" /> <ProjectReference Include="..\..\..\modules\identityServer\LINGYUN.Abp.IdentityServer.Application\LINGYUN.Abp.IdentityServer.Application.csproj" />
<ProjectReference Include="..\..\..\modules\identityServer\LINGYUN.Abp.IdentityServer.HttpApi\LINGYUN.Abp.IdentityServer.HttpApi.csproj" /> <ProjectReference Include="..\..\..\modules\identityServer\LINGYUN.Abp.IdentityServer.HttpApi\LINGYUN.Abp.IdentityServer.HttpApi.csproj" />

2
aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/PlatformHttpApiHostModule.cs

@ -1,6 +1,7 @@
using DotNetCore.CAP; using DotNetCore.CAP;
using IdentityModel; using IdentityModel;
using LINGYUN.Abp.EventBus.CAP; using LINGYUN.Abp.EventBus.CAP;
using LINGYUN.Abp.Identity;
using LINGYUN.Abp.IdentityServer; using LINGYUN.Abp.IdentityServer;
using LINGYUN.Abp.SettingManagement; using LINGYUN.Abp.SettingManagement;
using LINGYUN.Abp.TenantManagement; using LINGYUN.Abp.TenantManagement;
@ -70,6 +71,7 @@ namespace LINGYUN.Platform
typeof(AbpAspNetCoreAuthenticationJwtBearerModule), typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpCAPEventBusModule), typeof(AbpCAPEventBusModule),
typeof(AbpAliyunSmsModule), typeof(AbpAliyunSmsModule),
typeof(AbpIdentityOverrideOptionsModule),
typeof(AbpAutofacModule) typeof(AbpAutofacModule)
)] )]
public class PlatformHttpApiHostModule : AbpModule public class PlatformHttpApiHostModule : AbpModule

1
vueJs/.env.development

@ -8,6 +8,7 @@ VUE_APP_BASE_IDENTITY_SERVICE = '/api/identity'
VUE_APP_BASE_IDENTITY_SERVER = '/connect' VUE_APP_BASE_IDENTITY_SERVER = '/connect'
VUE_APP_TENANT_NAME = ''
VUE_APP_CLIENT_ID = 'vue-admin-element' VUE_APP_CLIENT_ID = 'vue-admin-element'
VUE_APP_CLIENT_SECRET = '1q2w3e*' VUE_APP_CLIENT_SECRET = '1q2w3e*'

4
vueJs/src/api/users.ts

@ -118,6 +118,10 @@ export default class UserApiService {
}) })
} }
public static refreshToken() {
}
public static userLogout(token: string | undefined) { public static userLogout(token: string | undefined) {
if (token) { if (token) {
const _url = '/connect/revocation' const _url = '/connect/revocation'

2
vueJs/src/permission.ts

@ -33,7 +33,7 @@ router.beforeEach(async(to: Route, _: Route, next: any) => {
NProgress.done() NProgress.done()
} else { } else {
// Check whether the user has obtained his permission roles // Check whether the user has obtained his permission roles
if (PermissionModule.routes.length === 0) { if (PermissionModule.authorizedPermissions.length === 0) {
try { try {
// Note: roles must be a object array! such as: ['admin'] or ['developer', 'editor'] // Note: roles must be a object array! such as: ['admin'] or ['developer', 'editor']
const { sub } = await UserModule.GetUserInfo() const { sub } = await UserModule.GetUserInfo()

5
vueJs/src/store/modules/permission.ts

@ -59,8 +59,13 @@ class Permission extends VuexModule implements IPermissionState {
} }
}) })
}) })
if (authPermissions.length === 0) {
// 防止没有任何权限无限刷新页面
this.SET_AUTHPERMISSIONS(['guest'])
} else {
this.SET_AUTHPERMISSIONS(authPermissions) this.SET_AUTHPERMISSIONS(authPermissions)
} }
}
@Action @Action
public async GenerateRoutes(userId: string) { public async GenerateRoutes(userId: string) {

21
vueJs/src/store/modules/user.ts

@ -92,22 +92,6 @@ class User extends VuexModule implements IUserState {
return userInfo 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 @Action
public async LogOut() { public async LogOut() {
if (this.token === '') { if (this.token === '') {
@ -124,6 +108,11 @@ class User extends VuexModule implements IUserState {
this.SET_TOKEN('') this.SET_TOKEN('')
this.SET_ROLES([]) this.SET_ROLES([])
} }
@Action
public RefreshSession() {
}
} }
export const UserModule = getModule(User) export const UserModule = getModule(User)

5
vueJs/src/views/login/index.vue

@ -28,6 +28,7 @@
tabindex="1" tabindex="1"
autocomplete="on" autocomplete="on"
/> />
</el-form-item>
<el-form-item prop="username"> <el-form-item prop="username">
<span class="svg-container"> <span class="svg-container">
@ -84,7 +85,6 @@
> >
{{ $t('login.logIn') }} {{ $t('login.logIn') }}
</el-button> </el-button>
</el-form-item>
</el-form> </el-form>
<el-dialog <el-dialog
@ -104,9 +104,8 @@
import { Component, Vue, Watch } from 'vue-property-decorator' import { Component, Vue, Watch } from 'vue-property-decorator'
import { Route } from 'vue-router' import { Route } from 'vue-router'
import { Dictionary } from 'vue-router/types/router' import { Dictionary } from 'vue-router/types/router'
import { Form as ElForm, Input, Message } from 'element-ui' import { Form as ElForm, Input } from 'element-ui'
import { UserModule } from '@/store/modules/user' import { UserModule } from '@/store/modules/user'
import { isValidUsername } from '@/utils/validate'
import LangSelect from '@/components/LangSelect/index.vue' import LangSelect from '@/components/LangSelect/index.vue'
import SocialSign from './components/SocialSignin.vue' import SocialSign from './components/SocialSignin.vue'

Loading…
Cancel
Save