From 0ece3ba8c92df0438af52b8de6b9225d8ada4103 Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期四, 30 十一月 2023 08:46:34 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/CanadaMes

---
 springboot-vue3/src/main/java/com/example/springboot/security/util/SecurityUtil.java |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/springboot-vue3/src/main/java/com/example/springboot/security/util/SecurityUtil.java b/springboot-vue3/src/main/java/com/example/springboot/security/util/SecurityUtil.java
new file mode 100644
index 0000000..bbcb410
--- /dev/null
+++ b/springboot-vue3/src/main/java/com/example/springboot/security/util/SecurityUtil.java
@@ -0,0 +1,20 @@
+package com.example.springboot.security.util;
+
+import com.example.springboot.entity.User;
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.subject.Subject;
+
+public class SecurityUtil {
+    /**
+     * 鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛
+     *
+     * @return
+     */
+    public static User getCurrentUser() {
+        Subject subject = SecurityUtils.getSubject();
+        if (!subject.isAuthenticated() && !subject.isRemembered()) {
+            throw new RuntimeException("Log current user error: UnAuthenticated subject");
+        }
+        return (User) subject.getPrincipal();
+    }
+}
\ No newline at end of file

--
Gitblit v1.8.0