Skip to content

Commit

Permalink
resolved bugs with Servlet Link
Browse files Browse the repository at this point in the history
  • Loading branch information
DLindenbauer committed Jan 2, 2017
1 parent 54c6c2b commit 102f597
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ public HelperServlet(final UserManager userManager, final LoginUriProvider login
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
if(isHdwServlet)
checkHardwarePremission(response);
checkHardwarePremission(response, request);
else
checkPermission(request, response);

}

@Override
Expand Down Expand Up @@ -113,7 +112,7 @@ private URI getUri(HttpServletRequest request) {
return URI.create(builder.toString());
}

private void checkHardwarePremission(HttpServletResponse response) throws IOException
private void checkHardwarePremission(HttpServletResponse response, HttpServletRequest request) throws IOException
{
System.out.println("------------Checking Hardware Premission --------------------");
HardwarePremissionCondition hdwpremission = new HardwarePremissionCondition(null, userManager,
Expand All @@ -123,7 +122,7 @@ private void checkHardwarePremission(HttpServletResponse response) throws IOExce

ApplicationUser applicationUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
if(applicationUser == null) {
redirectToLogin(null, response);
redirectToLogin(request, response);
}
else if(!permissionCondition.isApproved(applicationUser)) {
if(!hdwpremission.approvedHardwareUser(applicationUser)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import org.catrobat.jira.adminhelper.activeobject.ReadOnlyHdwGroupService;
import org.catrobat.jira.adminhelper.activeobject.ReadOnlyHdwUserService;

import java.util.Collection;

public class HardwarePremissionCondition extends JiraGlobalPermissionCondition {

private final UserManager userManager;
Expand Down Expand Up @@ -49,15 +51,18 @@ private boolean isReadonlyHardwareUser(ApplicationUser applicationUser)

private boolean hasPermission(ApplicationUser applicationUser)
{
if(adminHelperConfigService.getConfiguration().getApprovedGroups().length == 0 &&
adminHelperConfigService.getConfiguration().getApprovedUsers().length == 0)
return true;

if(isReadonlyHardwareUser(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()))
if(applicationUser == null || !ComponentAccessor.getUserUtil().getJiraSystemAdministrators().contains(applicationUser)) {
return isReadonlyHardwareUser(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser());
}
else if(adminHelperConfigService.isUserApproved(applicationUser.getKey())) {
return true;
}

else if(adminHelperConfigService.isUserApproved(applicationUser.getKey()))
return true;
Collection<String> groupNameCollection = groupManager.getGroupNamesForUser(applicationUser);
for (String groupName : groupNameCollection) {
if (adminHelperConfigService.isGroupApproved(groupName))
return true;
}

return false;
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/js/admin_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function sendDataToServer(url)
git_config.githubTokenPublic = AJS.$("#github_token_public").val();
git_config.githubOrganization = AJS.$("#github_organization").val();
git_config.defaultGithubTeam = AJS.$("#default-github-team").auiSelect2("val")

AJS.$.ajax({
url: url + "/rest/admin-helper/1.0/config/saveGithubConfig",
type: "PUT",
Expand All @@ -45,7 +45,6 @@ function sendDataToServer(url)
title: "Success!",
body: "Github Settings were successfully saved!"
});
populateForm();
},
error: function (error) {
AJS.messages.error({
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/js/hardware.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ AJS.toInit(function () {

function initHardwareVelocityReadonly(baseUrl) {
readOnly = true;
setReadOnlyProperties();
fillOutAllTables(baseUrl);
handleEvents(baseUrl);
initIndividualRelatedLendingTab(baseUrl);
initGroupUserSearchField(baseUrl);
setReadOnlyProperties();
}

function initHardwareVelocityAdmin(baseUrl)
Expand Down

0 comments on commit 102f597

Please sign in to comment.