Forráskód Böngészése

移动端登陆验证调整

徐滕 3 órája
szülő
commit
572055b0dd

+ 27 - 0
jeeplus-auth/src/main/java/com/jeeplus/auth/controller/LoginController.java

@@ -128,6 +128,9 @@ public class LoginController {
         SecurityUtils.login ( username, password, authenticationManager ); //登录操作
 
         String domain = RequestUtils.getHeader ( "domain" );
+        if(domain.contains("ydddl")){
+            domain = getIp(domain);
+        }
         if (domain.contains("ydddl")){
 
         } else {
@@ -181,6 +184,24 @@ public class LoginController {
         return responseUtil.ok ( );
     }
 
+
+    /**
+     * 从url中获取ip地址(移动端数据处理)
+     * @param url
+     * @return
+     */
+    public static String getIp(String url) {
+        // 去掉 http:// 或 https://
+        String withoutHttp = url.replaceAll("^https?://", "");
+
+        // 截取到第一个 : 为止
+        int index = withoutHttp.indexOf(":");
+        if (index != -1) {
+            return withoutHttp.substring(0, index);
+        }
+        return withoutHttp;
+    }
+
     /**
      * 用户登录
      *
@@ -211,6 +232,9 @@ public class LoginController {
         SecurityUtils.login ( username, "Xg@sys9hB2!xWm", authenticationManager ); //登录操作spring security
 
         String domain = RequestUtils.getHeader ( "domain" );
+        if(domain.contains("ydddl")){
+            domain = getIp(domain);
+        }
         if (domain.contains("ydddl")){
 
         } else {
@@ -291,6 +315,9 @@ public class LoginController {
         SecurityUtils.login ( username, "Xg@sys9hB2!xWm", authenticationManager ); //登录操作
 
         String domain = RequestUtils.getHeader ( "domain" );
+        if(domain.contains("ydddl")){
+            domain = getIp(domain);
+        }
         if (domain.contains("ydddl")){
 
         } else {

+ 24 - 2
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/service/UserService.java

@@ -240,9 +240,13 @@ public class UserService extends ServiceImpl<UserMapper, User> {
             queryWrapper.eq("a.del_flag", CommonConstants.NOT_DELETED);
 
             String domain = RequestUtils.getHeader("domain");
-            if (domain.contains("ydddl")) {
-                tenantId = "";
+
+            if(domain.contains("ydddl")){
+                domain = getIp(domain);
             }
+            /*if (domain.contains("ydddl")) {
+                tenantId = "";
+            }*/
 
             if (StringUtils.isNotBlank(tenantId)) {
                 queryWrapper.eq("a.tenant_id", tenantId);
@@ -255,6 +259,24 @@ public class UserService extends ServiceImpl<UserMapper, User> {
         return userDTO;
     }
 
+
+    /**
+     * 从url中获取ip地址(移动端数据处理)
+     * @param url
+     * @return
+     */
+    public static String getIp(String url) {
+        // 去掉 http:// 或 https://
+        String withoutHttp = url.replaceAll("^https?://", "");
+
+        // 截取到第一个 : 为止
+        int index = withoutHttp.indexOf(":");
+        if (index != -1) {
+            return withoutHttp.substring(0, index);
+        }
+        return withoutHttp;
+    }
+
     /**
      * 根据登录名获取用户
      *

+ 21 - 0
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/utils/TenantUtils.java

@@ -25,10 +25,14 @@ public class TenantUtils {
          * 如果用户未登录,根据域名获取租户id
          */
         String domain = RequestUtils.getHeader ( "domain" );
+        if(domain.contains("ydddl")){
+            domain = getIp(domain);
+        }
         if ( domain == null ) {
             return CommonConstants.DEFAULT_TENANT_ID; // 返回默认租户
         }
 
+
         String tenantId = (String) RedisUtils.getInstance ( ).get ( CacheNames.SYS_CACHE_TENANT, domain );
         if ( tenantId == null ) {
             Tenant tenant = SpringUtil.getBean ( TenantService.class ).lambdaQuery ( ).eq ( Tenant::getDomain, domain ).one ( );
@@ -56,4 +60,21 @@ public class TenantUtils {
 
     }
 
+    /**
+     * 从url中获取ip地址(移动端数据处理)
+     * @param url
+     * @return
+     */
+    public static String getIp(String url) {
+        // 去掉 http:// 或 https://
+        String withoutHttp = url.replaceAll("^https?://", "");
+
+        // 截取到第一个 : 为止
+        int index = withoutHttp.indexOf(":");
+        if (index != -1) {
+            return withoutHttp.substring(0, index);
+        }
+        return withoutHttp;
+    }
+
 }