Проброс на контроллеры и сами контроллеры
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package ru.ldeloff.hedgehogcloud.config;
|
||||
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.authority.AuthorityUtils;
|
||||
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -9,17 +8,11 @@ import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
public class AuthenticationSuccessUserHandler implements AuthenticationSuccessHandler {
|
||||
@Override
|
||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
||||
Set<String> roles = AuthorityUtils.authorityListToSet(authentication.getAuthorities());
|
||||
if (roles.contains("ROLE_ADMIN")) {
|
||||
response.sendRedirect("/admin");
|
||||
} else {
|
||||
response.sendRedirect("/user");
|
||||
}
|
||||
response.sendRedirect("/files");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user