mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-04 22:41:24 +08:00
Added permission control for WorkController
This commit is contained in:
@@ -16,7 +16,7 @@ public class WebUtil {
|
||||
}
|
||||
|
||||
public static String objectResponse(int resultCode, String msg, Object object) throws JsonProcessingException {
|
||||
ResponseResult result = ResponseResult.build(resultCode, msg, object);
|
||||
ResponseResult<Object> result = ResponseResult.build(resultCode, msg, object);
|
||||
return convert2json(result);
|
||||
}
|
||||
|
||||
@@ -32,4 +32,17 @@ public class WebUtil {
|
||||
Object principal = authentication.getPrincipal();
|
||||
return (LoginUser) principal;
|
||||
}
|
||||
|
||||
public static boolean hasAuthority(String authority) {
|
||||
return hasAnyAuthority(authority);
|
||||
}
|
||||
|
||||
public static boolean hasAnyAuthority(String... authorities) {
|
||||
for (String authority : authorities) {
|
||||
if (getLoginUser().getAuthorities().stream().anyMatch(grantedAuthority -> grantedAuthority.getAuthority().equals(authority))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user