com.dream.utils.SecurityHelper Maven / Gradle / Ivy
package com.dream.utils;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.User;
public class SecurityHelper {
public static boolean isLogged() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication != null && authentication.getPrincipal() instanceof User) {
return authentication.isAuthenticated();
}
return false;
}
}