快捷登录接口修改

parent f6514d1a
......@@ -84,27 +84,25 @@ public ApiResponse<JwtToken> Login([FromBody] LoginRequest request)
/// <summary>
/// 快速登录
/// </summary>
/// <param name="userId">登录目标用户id</param>
/// <param name="request"></param>
/// <returns></returns>
[Route("quick/login/{userId}")]
[Route("quick/login")]
[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(userId, loginUserId, request.Password);
var user = _userService.QuickLogin(request.TargetUserId, request.CurrentUserId, request.Password);
if (user == null)
return new ApiResponse<JwtToken>(ResponseType.Fail, "用户不存在");
var userClaim = _claim.GetUserClaim();
var claims = new Claim[]
{
new Claim(JwtClaimTypes.Id, user.UserID.ToString()),
new Claim(JwtClaimTypes.Login, user.Login),
new Claim(JwtClaimTypes.RealName, user.RealName),
new Claim(JwtClaimTypes.Mail, user.Mail??""),
new Claim(JwtClaimTypes.AppName, userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.AppName)?.Value ?? ""),
new Claim(JwtClaimTypes.Device, userClaim.FirstOrDefault(t => t.Type == JwtClaimTypes.Device)?.Value ?? ""),
new Claim(JwtClaimTypes.AppName, request.AppName ?? ""),
new Claim(JwtClaimTypes.Device, request.Device ?? ""),
new Claim(JwtClaimTypes.Department, user.Department ?? ""),
};
......
......@@ -6,5 +6,15 @@ public class ResetPwdRequest
/// 操作人密码
/// </summary>
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
{
var loginUser = _userRepository.GetEntity(t => t.ID == loginUserId && t.IsDelete == 1);
if (loginUser == null)
throw new PerformanceException($"您的登录信息有误,请退出后重新登录重试!");
throw new PerformanceException($"您的账号信息有误,请稍后重试!");
if (loginUser.Password != PwdHelper.MD5AndSalt(password))
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