fixed damaged deleting slots, see #5

This commit is contained in:
Jottyfan
2024-11-11 23:03:21 +01:00
parent a1ad23920a
commit bf88306d85
12 changed files with 59 additions and 25 deletions

View File

@ -42,7 +42,7 @@ public abstract class CommonController {
return false;
}
}
@ModelAttribute("hasDateRole")
public Boolean hasDateRole(Principal principal) {
OAuth2AuthenticationToken token = (OAuth2AuthenticationToken) principal;
@ -56,6 +56,21 @@ public abstract class CommonController {
return false;
}
}
@ModelAttribute("hasAnyRole")
public Boolean hasAnyRole(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.size() > 0;
} else {
LOGGER.warn("token is null, no roles can be detected");
return false;
}
}
/**
* get the theme for the current session
*