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

Commit

Permalink
Allowing anyone admin moved project/repo #240
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Aug 2, 2017
1 parent aa4af99 commit 6f690ab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ Changelog of Pull Request Notifier for Bitbucket.
### GitHub [#237](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/237) Listing all notifications via API takes a long time
Speeding up restriction filter

[e5b6bd9882559e8](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/e5b6bd9882559e8) Tomas Bjerre *2017-08-02 18:06:39*
[aa4af99648b9389](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/aa4af99648b9389) Tomas Bjerre *2017-08-02 18:07:08*

### GitHub [#240](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/240) Button config does not show up in the plugin config page.
Allowing anyone admin moved project/repo

[ba3d3c131a3d3da](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/ba3d3c131a3d3da) Tomas Bjerre *2017-08-02 19:49:14*

### No issue
doc
Expand Down
20 changes: 12 additions & 8 deletions src/main/java/se/bjurr/prnfb/service/UserCheckService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import static com.atlassian.bitbucket.permission.Permission.REPO_ADMIN;
import static com.atlassian.bitbucket.permission.Permission.SYS_ADMIN;
import static com.google.common.base.Strings.emptyToNull;
import static com.google.common.base.Throwables.propagate;
import static com.google.common.collect.Iterables.filter;
import static org.slf4j.LoggerFactory.getLogger;
import static se.bjurr.prnfb.settings.USER_LEVEL.ADMIN;
Expand Down Expand Up @@ -84,7 +83,8 @@ public Project perform() throws Exception {
}
});
} catch (final Exception e) {
throw propagate(e);
LOG.error(e.getMessage(), e);
return null;
}
}

Expand All @@ -101,7 +101,8 @@ public Repository perform() throws Exception {
}
});
} catch (final Exception e) {
throw propagate(e);
LOG.error(e.getMessage(), e);
return null;
}
}

Expand All @@ -117,8 +118,11 @@ public boolean isAdmin(UserKey userKey, String projectKey, String repositorySlug
if (projectKey != null && repositorySlug == null) {
final Project project = getProject(projectKey);
if (project == null) {
LOG.error("Button with project " + projectKey + " configured. But no such project exists!");
return false;
LOG.error(
"Project "
+ projectKey
+ " configured. But no such project exists! Allowing anyone to admin.");
return true;
}
final boolean isAllowed = permissionService.hasProjectPermission(project, PROJECT_ADMIN);
if (isAllowed) {
Expand All @@ -130,12 +134,12 @@ public boolean isAdmin(UserKey userKey, String projectKey, String repositorySlug
final Repository repository = getRepo(projectKey, repositorySlug);
if (repository == null) {
LOG.error(
"Button with project "
"Project "
+ projectKey
+ " and repo "
+ repositorySlug
+ " configured. But no such repo exists!");
return false;
+ " configured. But no such repo exists! Allowing anyone to admin.");
return true;
}
return permissionService.hasRepositoryPermission(repository, REPO_ADMIN);
}
Expand Down

0 comments on commit 6f690ab

Please sign in to comment.