added next

This commit is contained in:
Jottyfan
2024-07-30 10:43:25 +02:00
parent aadfdfa9b5
commit e3ebc387bb
12 changed files with 436 additions and 139 deletions

View File

@ -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
*