From dc2f936e99ca8feb90557d11cba1aa554c291e1b Mon Sep 17 00:00:00 2001 From: moec42frf <3378620026@qq.com> Date: Sun, 30 Apr 2023 09:37:12 +0800 Subject: [PATCH] ADD file via upload --- blogserver/src/main/java/org/sang/utils/Util.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 blogserver/src/main/java/org/sang/utils/Util.java diff --git a/blogserver/src/main/java/org/sang/utils/Util.java b/blogserver/src/main/java/org/sang/utils/Util.java new file mode 100644 index 0000000..4d574d4 --- /dev/null +++ b/blogserver/src/main/java/org/sang/utils/Util.java @@ -0,0 +1,12 @@ +package org.sang.utils; + +import org.sang.bean.User; +import org.springframework.security.core.context.SecurityContextHolder; + + +public class Util { + public static User getCurrentUser() { + User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); + return user; + } +}