fix:修复生成的 token 缺失 id导致登录校验出错 (#378)

Co-authored-by: zhongbo <zb123456789>
This commit is contained in:
SingerDracula 2024-08-04 14:35:48 +08:00 committed by GitHub
parent c52a6ddaa1
commit c2ccdca147
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -63,6 +63,7 @@ public class AuthServiceImpl implements AuthService {
user.setUsername(userParam.getUsername());
user.setPassword(AuthUtil.hash256(userParam.getPassword()));
mongoRepository.save(user);
userParam.setId(user.getId());
return createTokenAndDeleteCaptcha(userParam);
}
@ -88,7 +89,8 @@ public class AuthServiceImpl implements AuthService {
//验证码
checkCaptchaIsCorrect(userParam.getCaptchaId(), userParam.getCaptcha());
//用户验证
userService.loadUserByUsernameAndPassword(userParam.getUsername(), userParam.getPassword());
User user = userService.loadUserByUsernameAndPassword(userParam.getUsername(), userParam.getPassword());
userParam.setId(user.getId());
//生成token
return createTokenAndDeleteCaptcha(userParam);
}