v0.2.12 登录校验修正

v0.2o
bruce 2025-03-24 11:16:00 +08:00
parent 252ea9f769
commit 791e438b99
2 changed files with 3 additions and 0 deletions

View File

@ -27,6 +27,7 @@ public class AuthController {
@PostMapping("/login")
public AjaxResult login(@RequestBody LoginRequest loginRequest) {
// 认证成功,返回 JWT 令牌
System.out.println(loginRequest.toString());
String token = authService.authenticate(loginRequest);
return AjaxResult.success("登录成功", token);
}

View File

@ -47,6 +47,7 @@ public class AuthServiceImpl implements AuthService {
} else if (!loginRequest.getEmail().isEmpty()) {
user = userMapper.findByEmail(loginRequest.getEmail());
}
System.out.println(user);
// 用户不存在
if (user == null) {
throw new UserNotFoundException();
@ -54,6 +55,7 @@ public class AuthServiceImpl implements AuthService {
// 检查密码是否匹配
if (!PasswordUtil.matches(loginRequest.getPassword(), user.getPassword())) {
throw new PasswordIncorrectException();
}