Skip to content
This repository has been archived by the owner on Jun 9, 2021. It is now read-only.

Commit

Permalink
Avoiding crash when administring global admin page as admin #129
Browse files Browse the repository at this point in the history
 * Did not correctly check for repo level admin privilegies.
  • Loading branch information
tomasbjerre committed Jul 5, 2016
1 parent 021d750 commit 067014d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
20 changes: 18 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

Changelog of Pull Request Notifier for Bitbucket.

## Unreleased
### GitHub [#129](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/129) Unable to use wildcard for 'Repository'
Avoiding crash when administring global admin page as admin

* Did not correctly check for repo level admin privilegies.

[7404bb4bb5016c7](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/7404bb4bb5016c7) Tomas Bjerre *2016-07-05 20:31:25*

## 2.28
### No issue
Doc

[620ae59a58aaa9d](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/620ae59a58aaa9d) Tomas Bjerre *2016-06-29 18:47:19*

## 2.27
### GitHub [#128](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/128) Trigger button not showing up.
Making buttons compatible with 4.7.1
Expand Down Expand Up @@ -247,12 +261,12 @@ and a lot easier to add multiple actions.
### GitHub [#93](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/93) Get reviewers of pr
update: update changelog.md and readme.md.

[60732c85dbda9a8](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/60732c85dbda9a8) 张盟 *2016-01-25 14:24:07*
[60732c85dbda9a8](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/60732c85dbda9a8) ?? *2016-01-25 14:24:07*

### No issue
update: support reviewers list

[fcd612e0d9512a2](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/fcd612e0d9512a2) 张盟 *2016-01-25 09:15:49*
[fcd612e0d9512a2](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/fcd612e0d9512a2) ?? *2016-01-25 09:15:49*

Correcting link to blog post in README.md

Expand Down Expand Up @@ -751,6 +765,8 @@ java.util.Base64 is available since 1.8 and javax.xml.bind.DatatypeConverter sin

[36f99c11d31c763](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/36f99c11d31c763) Raimana *2015-04-01 09:24:20*

## 1.1
### No issue
Adding support for PULL_REQUEST_FROM/TO_HASH, filters and fixing authentication bug
* Making it compatible with Stash 2.12.0
* Some more documentation
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/se/bjurr/prnfb/service/UserCheckService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static com.atlassian.bitbucket.permission.Permission.PROJECT_ADMIN;
import static com.atlassian.bitbucket.permission.Permission.REPO_ADMIN;
import static com.google.common.base.Strings.emptyToNull;
import static com.google.common.collect.Iterables.filter;
import static se.bjurr.prnfb.settings.USER_LEVEL.ADMIN;
import static se.bjurr.prnfb.settings.USER_LEVEL.EVERYONE;
Expand Down Expand Up @@ -54,6 +55,10 @@ public boolean isAdmin(UserKey userKey, String projectKey, String repositorySlug
if (isAdmin) {
return isAdmin;
}

projectKey = emptyToNull(projectKey);
repositorySlug = emptyToNull(repositorySlug);

if (projectKey != null && repositorySlug == null) {
Project project = this.projectService.getByKey(projectKey);
return this.permissionService.hasProjectPermission(project, PROJECT_ADMIN);
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ define('plugin/prnfb/admin', [
'aui',
'plugin/prnfb/utils'
], function($, AJS, utils) {
var settingsAdminUrlPostUrl = AJS.contextPath() + "/rest/prnfb-admin/1.0/settings"; 
var settingsAdminUrlPostUrl = AJS.contextPath() + "/rest/prnfb-admin/1.0/settings";
var settingsAdminUrl = settingsAdminUrlPostUrl;

var notificationsAdminUrlPostUrl = AJS.contextPath() + "/rest/prnfb-admin/1.0/settings/notifications"; 
var notificationsAdminUrlPostUrl = AJS.contextPath() + "/rest/prnfb-admin/1.0/settings/notifications";
var notificationsAdminUrl = notificationsAdminUrlPostUrl;

var buttonsAdminUrlPostUrl = AJS.contextPath() + "/rest/prnfb-admin/1.0/settings/buttons"; 
var buttonsAdminUrlPostUrl = AJS.contextPath() + "/rest/prnfb-admin/1.0/settings/buttons";
var buttonsAdminUrl = buttonsAdminUrlPostUrl;

if ($('#prnfbRepositorySlug').length !== 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ define('plugin/prnfb/utils', [
}

function getProjects(whenDone) {
var projectsUrl = AJS.contextPath() + "/rest/api/1.0/projects?limit=999999"; 
var projectsUrl = AJS.contextPath() + "/rest/api/1.0/projects?limit=999999";
$.getJSON(projectsUrl, function(data) {
whenDone(data);
});
Expand Down Expand Up @@ -83,7 +83,7 @@ define('plugin/prnfb/utils', [
whenDone();
return;
}
var reposUrl = AJS.contextPath() + "/rest/api/1.0/projects/" + projectKey + "/repos?limit=999999"; 
var reposUrl = AJS.contextPath() + "/rest/api/1.0/projects/" + projectKey + "/repos?limit=999999";
$.getJSON(reposUrl, function(data) {
whenDone(data);
});
Expand Down

0 comments on commit 067014d

Please sign in to comment.