From 8a82d82083d777cb08a3b80a00beb6512b7c98cf Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期五, 30 八月 2024 20:30:34 +0800
Subject: [PATCH] 解密

---
 se-auth/src/main/resources/bootstrap.yml                          |    1 +
 se-modules/se-system/src/main/resources/bootstrap.yml             |    2 +-
 se-auth/src/main/java/com/se/auth/controller/TokenController.java |   10 +++++++++-
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/se-auth/src/main/java/com/se/auth/controller/TokenController.java b/se-auth/src/main/java/com/se/auth/controller/TokenController.java
index 273d9ef..3f34d1f 100644
--- a/se-auth/src/main/java/com/se/auth/controller/TokenController.java
+++ b/se-auth/src/main/java/com/se/auth/controller/TokenController.java
@@ -5,7 +5,9 @@
 import com.se.auth.form.LoginBody;
 import com.se.auth.form.RegisterBody;
 import com.se.auth.service.SysLoginService;
+import com.se.common.core.utils.AesUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 import com.se.common.core.domain.R;
 import com.se.common.core.utils.JwtUtils;
@@ -28,8 +30,14 @@
     @Autowired
     private SysLoginService sysLoginService;
 
+    @Value("${enableEncrypt}")
+    boolean enableEncrypt;
+
     @PostMapping("login")
-    public R<?> login(@RequestBody LoginBody form) {
+    public R<?> login(@RequestBody LoginBody form) throws Exception {
+        if (enableEncrypt && !StringUtils.isEmpty(form.getPassword())) {
+            form.setPassword(AesUtils.decrypt(form.getPassword()));
+        }
         // 鐢ㄦ埛鐧诲綍
         LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
         // 鑾峰彇鐧诲綍token
diff --git a/se-auth/src/main/resources/bootstrap.yml b/se-auth/src/main/resources/bootstrap.yml
index 5e1086f..8006d1a 100644
--- a/se-auth/src/main/resources/bootstrap.yml
+++ b/se-auth/src/main/resources/bootstrap.yml
@@ -25,3 +25,4 @@
         # 鍏变韩閰嶇疆
         shared-configs:
           - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+enableEncrypt: false
\ No newline at end of file
diff --git a/se-modules/se-system/src/main/resources/bootstrap.yml b/se-modules/se-system/src/main/resources/bootstrap.yml
index 9f8233b..8f3aeec 100644
--- a/se-modules/se-system/src/main/resources/bootstrap.yml
+++ b/se-modules/se-system/src/main/resources/bootstrap.yml
@@ -25,4 +25,4 @@
         # 鍏变韩閰嶇疆
         shared-configs:
           - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
-enableEncrypt: true
\ No newline at end of file
+enableEncrypt: false
\ No newline at end of file

--
Gitblit v1.9.3