Spaces:
Sleeping
Sleeping
Fix performance
Browse files
src/main/java/com/darkfantasy/util/SecurityUtil.java
CHANGED
|
@@ -13,7 +13,9 @@ import lombok.experimental.UtilityClass;
|
|
| 13 |
public class SecurityUtil {
|
| 14 |
public String getCurrentUserName() {
|
| 15 |
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
| 16 |
-
if (authentication == null
|
|
|
|
|
|
|
| 17 |
return null;
|
| 18 |
}
|
| 19 |
return authentication.getName();
|
|
|
|
| 13 |
public class SecurityUtil {
|
| 14 |
public String getCurrentUserName() {
|
| 15 |
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
| 16 |
+
if (authentication == null
|
| 17 |
+
|| !authentication.isAuthenticated()
|
| 18 |
+
|| authentication instanceof AnonymousAuthenticationToken) {
|
| 19 |
return null;
|
| 20 |
}
|
| 21 |
return authentication.getName();
|