mirror of
https://github.com/HangarMC/Hangar.git
synced 2024-12-21 06:51:19 +08:00
fix project apiv2 NPEing for anon access
This commit is contained in:
parent
0f88e0492c
commit
0ae98abe7f
@ -71,7 +71,8 @@ public class ProjectsApiController implements ProjectsApi {
|
||||
|
||||
UsersTable currentUser = userService.getCurrentUser();
|
||||
// TODO this is really meh, we want to save global permissions somewhere
|
||||
boolean seeHidden = permissionService.getGlobalPermissions(currentUser.getId()).has(Permission.SeeHidden);
|
||||
boolean seeHidden = currentUser != null && permissionService.getGlobalPermissions(currentUser.getId()).has(Permission.SeeHidden);
|
||||
Long requesterId = currentUser == null ? null : currentUser.getId();
|
||||
|
||||
List<Project> projects = projectService.getProjects(
|
||||
null,
|
||||
@ -80,7 +81,7 @@ public class ProjectsApiController implements ProjectsApi {
|
||||
q,
|
||||
owner,
|
||||
seeHidden,
|
||||
currentUser.getId(),
|
||||
requesterId,
|
||||
sort,
|
||||
relevance,
|
||||
limit,
|
||||
@ -94,7 +95,7 @@ public class ProjectsApiController implements ProjectsApi {
|
||||
q,
|
||||
owner,
|
||||
seeHidden,
|
||||
currentUser.getId()
|
||||
requesterId
|
||||
);
|
||||
|
||||
PaginatedProjectResult result = new PaginatedProjectResult();
|
||||
|
@ -193,11 +193,11 @@ public class ProjectService {
|
||||
return projectDao.get().getUnhealthyProjects(hangarConfig.projects.getStaleAge().toMillis());
|
||||
}
|
||||
|
||||
public List<Project> getProjects(String pluginId, List<Category> categories, List<Tag> parsedTags, String query, String owner, boolean seeHidden, long requesterId, ProjectSortingStrategy sort, boolean relevance, long limit, long offset) {
|
||||
public List<Project> getProjects(String pluginId, List<Category> categories, List<Tag> parsedTags, String query, String owner, boolean seeHidden, Long requesterId, ProjectSortingStrategy sort, boolean relevance, long limit, long offset) {
|
||||
return List.of(getProjectApi("test")); // TODO getProjects query
|
||||
}
|
||||
|
||||
public long countProjects(String pluginId, List<Category> categories, List<Tag> parsedTags, String query, String owner, boolean seeHidden, long requesterId) {
|
||||
public long countProjects(String pluginId, List<Category> categories, List<Tag> parsedTags, String query, String owner, boolean seeHidden, Long requesterId) {
|
||||
return 1; // TODO count projects query
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user