added next
This commit is contained in:
@ -42,7 +42,20 @@ public abstract class CommonController {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ModelAttribute("hasDiakoneRole")
|
||||
public Boolean hasDiakoneRole(Principal principal) {
|
||||
OAuth2AuthenticationToken token = (OAuth2AuthenticationToken) principal;
|
||||
if (token != null) {
|
||||
OAuth2User user = token.getPrincipal();
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> roles = (List<String>) user.getAttributes().get("roles");
|
||||
return roles.contains("Diakone");
|
||||
} else {
|
||||
LOGGER.warn("token is null, no roles can be detected");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* get the theme for the current session
|
||||
*
|
||||
|
Reference in New Issue
Block a user