From a802e41c317063baf081db05ff9a94460df80dc2 Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Thu, 14 Jan 2021 22:49:20 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90auth=E3=80=91=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kernel/auth/auth/AuthServiceImpl.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/kernel-d-auth/auth-sdk/src/main/java/cn/stylefeng/roses/kernel/auth/auth/AuthServiceImpl.java b/kernel-d-auth/auth-sdk/src/main/java/cn/stylefeng/roses/kernel/auth/auth/AuthServiceImpl.java index 7c614ca85..d7db5c30a 100644 --- a/kernel-d-auth/auth-sdk/src/main/java/cn/stylefeng/roses/kernel/auth/auth/AuthServiceImpl.java +++ b/kernel-d-auth/auth-sdk/src/main/java/cn/stylefeng/roses/kernel/auth/auth/AuthServiceImpl.java @@ -167,7 +167,7 @@ public class AuthServiceImpl implements AuthServiceApi { } } - //开启验证码 + // 2. 如果开启了验证码校验,则验证当前请求的验证码是否正确 if (SystemConfigExpander.getCaptchaOpen()) { String kaptcha = loginRequest.getKaptcha(); @@ -180,13 +180,13 @@ public class AuthServiceImpl implements AuthServiceApi { } } - // 2. 解密密码的密文 + // 3. 解密密码的密文 // String decryptPassword = passwordTransferEncryptApi.decrypt(loginRequest.getPassword()); - // 3. 获取用户密码的加密值和用户的状态 + // 4. 获取用户密码的加密值和用户的状态 UserLoginInfoDTO userValidateInfo = userServiceApi.getUserLoginInfo(loginRequest.getAccount()); - // 4. 校验用户密码是否正确 + // 5. 校验用户密码是否正确 if (validatePassword) { Boolean checkResult = passwordStoredEncryptApi.checkPassword(loginRequest.getPassword(), userValidateInfo.getUserPasswordHexed()); if (!checkResult) { @@ -194,37 +194,38 @@ public class AuthServiceImpl implements AuthServiceApi { } } - // 5. 校验用户是否异常(不是正常状态) + // 6. 校验用户是否异常(不是正常状态) if (!UserStatusEnum.ENABLE.getCode().equals(userValidateInfo.getUserStatus())) { String userTip = StrUtil.format(AuthExceptionEnum.USER_STATUS_ERROR.getErrorCode(), UserStatusEnum.getCodeMessage(userValidateInfo.getUserStatus())); throw new AuthException(AuthExceptionEnum.USER_STATUS_ERROR.getErrorCode(), userTip); } - // 6. 获取LoginUser,用于用户的缓存 + // 7. 获取LoginUser,用于用户的缓存 LoginUser loginUser = userValidateInfo.getLoginUser(); - // 7. 生成用户的token + // 8. 生成用户的token DefaultJwtPayload defaultJwtPayload = new DefaultJwtPayload(loginUser.getUserId(), loginUser.getAccount(), loginRequest.getRememberMe()); String jwtToken = JwtContext.me().generateTokenDefaultPayload(defaultJwtPayload); synchronized (SESSION_OPERATE_LOCK) { - // 8. 缓存用户信息,创建会话 + // 9. 缓存用户信息,创建会话 sessionManagerApi.createSession(jwtToken, loginUser); - // 9. 如果开启了单账号单端在线,则踢掉已经上线的该用户 + // 10. 如果开启了单账号单端在线,则踢掉已经上线的该用户 if (AuthConfigExpander.getSingleAccountLoginFlag()) { sessionManagerApi.removeSessionExcludeToken(jwtToken); } } - // 10. 更新用户登录时间和ip + // 11. 更新用户登录时间和ip String ip = HttpServletUtil.getRequestClientIp(HttpServletUtil.getRequest()); userServiceApi.updateUserLoginInfo(loginUser.getUserId(), new Date(), ip); - // 11.登录成功日志 + // 12.登录成功日志 loginLogServiceApi.loginSuccess(loginUser.getUserId()); - // 12. 组装返回结果 + + // 13. 组装返回结果 return new LoginResponse(loginUser, jwtToken, defaultJwtPayload.getExpirationDate()); }