快捷登录接口修改

parent f6514d1a
...@@ -84,27 +84,25 @@ public ApiResponse<JwtToken> Login([FromBody] LoginRequest request) ...@@ -84,27 +84,25 @@ public ApiResponse<JwtToken> Login([FromBody] LoginRequest request)
/// <summary> /// <summary>
/// 快速登录 /// 快速登录
/// </summary> /// </summary>
/// <param name="userId">登录目标用户id</param>
/// <param name="request"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
[Route("quick/login/{userId}")] [Route("quick/login")]
[HttpPost] [HttpPost]
public ApiResponse<JwtToken> QuickLogin(int userId, [FromBody] ResetPwdRequest request) [AllowAnonymous]
public ApiResponse<JwtToken> QuickLogin([FromBody] ResetPwdRequest request)
{ {
var loginUserId = _claim.GetUserId(); var user = _userService.QuickLogin(request.TargetUserId, request.CurrentUserId, request.Password);
var user = _userService.QuickLogin(userId, loginUserId, request.Password);
if (user == null) if (user == null)
return new ApiResponse<JwtToken>(ResponseType.Fail, "用户不存在"); return new ApiResponse<JwtToken>(ResponseType.Fail, "用户不存在");
var userClaim = _claim.GetUserClaim();
var claims = new Claim[] var claims = new Claim[]
{ {
new Claim(JwtClaimTypes.Id, user.UserID.ToString()), new Claim(JwtClaimTypes.Id, user.UserID.ToString()),
new Claim(JwtClaimTypes.Login, user.Login), new Claim(JwtClaimTypes.Login, user.Login),
new Claim(JwtClaimTypes.RealName, user.RealName), new Claim(JwtClaimTypes.RealName, user.RealName),
new Claim(JwtClaimTypes.Mail, user.Mail??""), new Claim(JwtClaimTypes.Mail, user.Mail??""),
new Claim(JwtClaimTypes.AppName, userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.AppName)?.Value ?? ""), new Claim(JwtClaimTypes.AppName, request.AppName ?? ""),
new Claim(JwtClaimTypes.Device, userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.Device)?.Value ?? ""), new Claim(JwtClaimTypes.Device, request.Device ?? ""),
new Claim(JwtClaimTypes.Department, user.Department ?? ""), new Claim(JwtClaimTypes.Department, user.Department ?? ""),
}; };
......
...@@ -6,5 +6,15 @@ public class ResetPwdRequest ...@@ -6,5 +6,15 @@ public class ResetPwdRequest
/// 操作人密码 /// 操作人密码
/// </summary> /// </summary>
public string Password { get; set; } public string Password { get; set; }
/// <summary>
/// 操作人密码
/// </summary>
public int CurrentUserId { get; set; }
/// <summary>
/// 目标登录人,希望登录的账号ID
/// </summary>
public int TargetUserId { get; set; }
public string AppName { get; set; }
public string Device { get; set; }
} }
} }
...@@ -96,7 +96,7 @@ public UserIdentity QuickLogin(int targetUserId, int loginUserId, string passwor ...@@ -96,7 +96,7 @@ public UserIdentity QuickLogin(int targetUserId, int loginUserId, string passwor
{ {
var loginUser = _userRepository.GetEntity(t => t.ID == loginUserId && t.IsDelete == 1); var loginUser = _userRepository.GetEntity(t => t.ID == loginUserId && t.IsDelete == 1);
if (loginUser == null) if (loginUser == null)
throw new PerformanceException($"您的登录信息有误,请退出后重新登录重试!"); throw new PerformanceException($"您的账号信息有误,请稍后重试!");
if (loginUser.Password != PwdHelper.MD5AndSalt(password)) if (loginUser.Password != PwdHelper.MD5AndSalt(password))
throw new PerformanceException($"您的密码错误,请重新输入后重试"); throw new PerformanceException($"您的密码错误,请重新输入后重试");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment