From 1bca1b9c61676b48cc3137d3003e520c75ecdd92 Mon Sep 17 00:00:00 2001 From: aijinhui <aijinhui> Date: 星期六, 13 一月 2024 10:57:36 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java | 20 +++++++++++++++++--- 1 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java index f3fa8aa..7e23657 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java @@ -1,9 +1,9 @@ package com.ruoyi.framework.web.service; import javax.annotation.Resource; - import com.ruoyi.rongcloud.service.RongCloudService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; @@ -36,6 +36,11 @@ */ @Component public class SysLoginService { + + // 鏄惁鍏佽璐︽埛澶氱粓绔悓鏃剁櫥褰曪紙true鍏佽 false涓嶅厑璁革級 + @Value("${token.soloLogin}") + private boolean soloLogin; + @Autowired private TokenService tokenService; @@ -65,7 +70,6 @@ */ public String login(String username, String password, String code, String uuid) { - boolean captchaEnabled = configService.selectCaptchaEnabled(); // 楠岃瘉鐮佸紑鍏� if (captchaEnabled) { @@ -92,7 +96,17 @@ AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"))); LoginUser loginUser = (LoginUser) authentication.getPrincipal(); recordLoginInfo(loginUser.getUserId()); - + if (!soloLogin) + { + // 濡傛灉鐢ㄦ埛涓嶅厑璁稿缁堢鍚屾椂鐧诲綍锛屾竻闄ょ紦瀛樹俊鎭� + String userIdKey = Constants.LOGIN_USERID_KEY + loginUser.getUser().getUserId(); + String userKey = redisCache.getCacheObject(userIdKey); + if (StringUtils.isNotEmpty(userKey)) + { + redisCache.deleteObject(userIdKey); + redisCache.deleteObject(userKey); + } + } getRongCloudToken(loginUser); // 鐢熸垚token String token = tokenService.createToken(loginUser); -- Gitblit v1.9.3