feat 用户解锁
This commit is contained in:
@@ -108,4 +108,14 @@ public class UsersController : ControllerBase
|
|||||||
{
|
{
|
||||||
await _userService.ResetPasswordAsync(request);
|
await _userService.ResetPasswordAsync(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户解锁
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
[HttpPost("unlock/{userId:int}")]
|
||||||
|
public async Task UnlockAsync(int userId)
|
||||||
|
{
|
||||||
|
await _userService.UnlockAsync(userId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -24,4 +24,7 @@ public interface IUserService : IScopeDependency
|
|||||||
Task ResetLoginTenantAsync(UserResetLoginTenantRequest request);
|
Task ResetLoginTenantAsync(UserResetLoginTenantRequest request);
|
||||||
|
|
||||||
Task ResetPasswordAsync(UserResetPasswordRequest request);
|
Task ResetPasswordAsync(UserResetPasswordRequest request);
|
||||||
|
|
||||||
|
|
||||||
|
Task UnlockAsync(int userId);
|
||||||
}
|
}
|
||||||
@@ -100,6 +100,17 @@ public class UserService : IUserService
|
|||||||
var user = await _identityDbContext.Queryable<UserEntity>().Where(x => x.Id == request.UserId).Select<UserResponse>().FirstAsync();
|
var user = await _identityDbContext.Queryable<UserEntity>().Where(x => x.Id == request.UserId).Select<UserResponse>().FirstAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task UnlockAsync(int userId)
|
||||||
|
{
|
||||||
|
var user = await _identityDbContext.Queryable<UserEntity>().SingleAsync(x => x.Id == userId);
|
||||||
|
user.ThrowIfNull("用户不存在");
|
||||||
|
|
||||||
|
user.LockoutEnd = null;
|
||||||
|
|
||||||
|
await _identityDbContext.UpdateAsync(user);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<List<UserResponse>> GetUserByIdsAsync(List<int> ids)
|
public async Task<List<UserResponse>> GetUserByIdsAsync(List<int> ids)
|
||||||
{
|
{
|
||||||
return await _identityDbContext.Queryable<UserEntity>()
|
return await _identityDbContext.Queryable<UserEntity>()
|
||||||
|
|||||||
Reference in New Issue
Block a user