From c2ccdca1471fd9706fd7c722d45761b3a089ee12 Mon Sep 17 00:00:00 2001 From: SingerDracula <547856757@qq.com> Date: Sun, 4 Aug 2024 14:35:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=9A=84=20token=20=E7=BC=BA=E5=A4=B1=20id=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=A0=A1=E9=AA=8C=E5=87=BA=E9=94=99=20(#378)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: zhongbo --- .../xiaojusurvey/engine/core/auth/impl/AuthServiceImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/survey-core/src/main/java/com/xiaojusurvey/engine/core/auth/impl/AuthServiceImpl.java b/survey-core/src/main/java/com/xiaojusurvey/engine/core/auth/impl/AuthServiceImpl.java index e5bfd75e..e984d337 100644 --- a/survey-core/src/main/java/com/xiaojusurvey/engine/core/auth/impl/AuthServiceImpl.java +++ b/survey-core/src/main/java/com/xiaojusurvey/engine/core/auth/impl/AuthServiceImpl.java @@ -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); }