Browse Source

👕 Abp5.0之后用户表添加IsActive 判断用户是否激活

pull/27/head
王军 5 years ago
parent
commit
9bc1e6f7da
  1. 8
      aspnet-core/frameworks/CAP/src/Lion.AbpPro.CAP/AbpProAbpCapConsumerServiceSelector.cs
  2. 5
      aspnet-core/frameworks/CAP/src/Lion.AbpPro.CAP/AbpProAbpCapDistributedEventBus.cs
  3. 11
      aspnet-core/services/src/Lion.AbpPro.Application/Users/AccountAppService.cs
  4. 12
      aspnet-core/services/src/Lion.AbpPro.Application/Users/UserAppService.cs
  5. 2
      vben271/src/locales/lang/en/common.ts
  6. 2
      vben271/src/locales/lang/zh-CN/common.ts
  7. 1
      vben271/src/locales/lang/zh-CN/routes/admin.ts
  8. 6
      vben271/src/views/admin/users/AbpUser.ts
  9. 10
      vben271/src/views/admin/users/AbpUser.vue

8
aspnet-core/frameworks/CAP/src/Lion.AbpPro.CAP/AbpProAbpCapConsumerServiceSelector.cs

@ -14,10 +14,10 @@ namespace Lion.AbpPro.CAP
{
[Dependency(ServiceLifetime.Singleton, ReplaceServices = true)]
[ExposeServices(typeof(IConsumerServiceSelector))]
public class AbpProAbpCapConsumerServiceSelector : ConsumerServiceSelector
public sealed class AbpProAbpCapConsumerServiceSelector : ConsumerServiceSelector
{
protected AbpDistributedEventBusOptions AbpDistributedEventBusOptions { get; }
protected IServiceProvider ServiceProvider { get; }
private AbpDistributedEventBusOptions AbpDistributedEventBusOptions { get; }
private IServiceProvider ServiceProvider { get; }
/// <summary>
/// Creates a new <see cref="T:DotNetCore.CAP.Internal.ConsumerServiceSelector" />.
@ -73,7 +73,7 @@ namespace Lion.AbpPro.CAP
return executorDescriptorList;
}
protected virtual IEnumerable<ConsumerExecutorDescriptor> GetHandlerDescription(Type eventType,Type typeInfo)
private IEnumerable<ConsumerExecutorDescriptor> GetHandlerDescription(Type eventType,Type typeInfo)
{
var serviceTypeInfo = typeof(IDistributedEventHandler<>)
.MakeGenericType(eventType);

5
aspnet-core/frameworks/CAP/src/Lion.AbpPro.CAP/AbpProAbpCapDistributedEventBus.cs

@ -27,9 +27,6 @@ namespace Lion.AbpPro.CAP
private readonly ICapPublisher CapPublisher;
private readonly UnitOfWorkManager _unitOfWorkManager;
private IEventHandlerInvoker EventHandlerInvoker { get; }
public AbpProAbpCapDistributedEventBus(IServiceScopeFactory serviceScopeFactory,
IOptions<AbpDistributedEventBusOptions> distributedEventBusOptions,
@ -40,8 +37,6 @@ namespace Lion.AbpPro.CAP
: base(serviceScopeFactory, currentTenant,unitOfWorkManager,eventHandlerInvoker)
{
CapPublisher = capPublisher;
_unitOfWorkManager = unitOfWorkManager;
EventHandlerInvoker = eventHandlerInvoker;
AbpDistributedEventBusOptions = distributedEventBusOptions.Value;
HandlerFactories = new ConcurrentDictionary<Type, List<IEventHandlerFactory>>();
EventTypes = new ConcurrentDictionary<string, Type>();

11
aspnet-core/services/src/Lion.AbpPro.Application/Users/AccountAppService.cs

@ -52,11 +52,10 @@ namespace Lion.AbpPro.Users
public async Task<LoginOutput> LoginAsync(LoginInput input)
{
var result =
await _signInManager.PasswordSignInAsync(input.Name, input.Password, false, true);
if (result.IsLockedOut)
var result = await _signInManager.PasswordSignInAsync(input.Name, input.Password, false, true);
if (result.IsNotAllowed)
{
throw new UserFriendlyException("当前用户已锁定");
throw new UserFriendlyException("当前用户已锁定");
}
if (!result.Succeeded)
@ -78,6 +77,10 @@ namespace Lion.AbpPro.Users
await _httpClientFactory.GetAsync<LoginStsOutput>(HttpClientNameConsts.Sts,
"connect/userinfo", headers);
var user = await _userManager.FindByNameAsync(response.name);
if (!user.IsActive)
{
throw new UserFriendlyException("当前用户已锁定");
}
return await BuildResult(user);
}

12
aspnet-core/services/src/Lion.AbpPro.Application/Users/UserAppService.cs

@ -133,16 +133,8 @@ namespace Lion.AbpPro.Users
public async Task LockAsync(LockUserInput input)
{
var identityUser = await _userManager.GetByIdAsync(input.UserId);
await _userManager.SetLockoutEnabledAsync(identityUser, input.Locked);
if (input.Locked)
{
// 如果锁定用户,锁定100年
await _userManager.SetLockoutEndDateAsync(identityUser, DateTimeOffset.UtcNow.AddYears(100));
}
else
{
await _userManager.SetLockoutEndDateAsync(identityUser, DateTimeOffset.UtcNow.AddDays(-1));
}
identityUser.SetIsActive(input.Locked);
await _userManager.UpdateAsync(identityUser);
}
}
}

2
vben271/src/locales/lang/en/common.ts

@ -30,4 +30,6 @@ export default {
action: 'Action',
creationTime: 'CreationTime',
detail: 'Detail',
status: 'Status',
active: 'IsActive',
};

2
vben271/src/locales/lang/zh-CN/common.ts

@ -33,4 +33,6 @@ export default {
key: '关键字',
creationTime: '创建时间',
detail: '详情',
status: '状态',
active: '是否激活',
};

1
vben271/src/locales/lang/zh-CN/routes/admin.ts

@ -21,7 +21,6 @@ export default {
roleManagement_create_role: '创建角色',
roleManagement_permission: '授权',
userManagement_locked: '锁定',
audit_executeTime: '执行时间',
audit_userName: '用户名',
audit_httpMethod: 'Http方法',

6
vben271/src/views/admin/users/AbpUser.ts

@ -38,9 +38,9 @@ export const tableColumns: BasicColumn[] = [
dataIndex: 'phoneNumber',
},
{
title: t('routes.admin.userManagement_locked'),
dataIndex: 'lockoutEnabled',
slots: { customRender: 'lockoutEnabled' },
title: t('common.status'),
dataIndex: 'isActive',
slots: { customRender: 'isActive' },
},
{
title: t('routes.admin.userManagement_createTime'),

10
vben271/src/views/admin/users/AbpUser.vue

@ -10,9 +10,9 @@
{{ t('common.createText') }}
</a-button>
</template>
<template #lockoutEnabled="{ record }">
<Tag :color="record.lockoutEnabled ? 'red' : 'green'">
{{ record.lockoutEnabled ? t('common.locked') : t('common.unLocked') }}
<template #isActive="{ record }">
<Tag :color="record.isActive ? 'green' : 'red'">
{{ record.isActive ? t('common.enabled') : t('common.disEnabled') }}
</Tag>
</template>
<template #action="{ record }">
@ -39,7 +39,7 @@
@click="handleLock(record)"
v-auth="'System.Users.Enable'"
>
{{ record.lockoutEnabled ? t('common.enabled') : t('common.disEnabled') }}
{{ !record.isActive ? t('common.enabled') : t('common.disEnabled') }}
</a-button>
</template>
</BasicTable>
@ -159,7 +159,7 @@
}
let request = new LockUserInput();
request.userId = record.id;
request.locked = !record.lockoutEnabled;
request.locked = !record.isActive;
await lockUserAsync(request);
message.success(t('common.operationSuccess'));
reload();

Loading…
Cancel
Save