From 8f1dc607d135fd99d769a2dfd1e11e00d72d0506 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Wed, 19 Nov 2014 11:34:17 -0500
Subject: [PATCH] Merged #223 "Add support for image/svg+xml content type to raw servlet"
---
src/main/java/com/gitblit/models/UserModel.java | 36 ++++++++++++++++++++++++++++++++----
1 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/gitblit/models/UserModel.java b/src/main/java/com/gitblit/models/UserModel.java
index 63208f3..e152274 100644
--- a/src/main/java/com/gitblit/models/UserModel.java
+++ b/src/main/java/com/gitblit/models/UserModel.java
@@ -67,6 +67,7 @@
public boolean canFork;
public boolean canCreate;
public boolean excludeFromFederation;
+ public boolean disabled;
// retained for backwards-compatibility with RPC clients
@Deprecated
public final Set<String> repositories = new HashSet<String>();
@@ -446,16 +447,29 @@
return canAdmin() || model.isUsersPersonalRepository(username) || model.isOwner(username);
}
+ public boolean canEdit(TicketModel ticket, RepositoryModel repository) {
+ return isAuthenticated() &&
+ (canPush(repository)
+ || (ticket != null && username.equals(ticket.responsible))
+ || (ticket != null && username.equals(ticket.createdBy)));
+ }
+
+ public boolean canAdmin(TicketModel ticket, RepositoryModel repository) {
+ return isAuthenticated() &&
+ (canPush(repository)
+ || ticket != null && username.equals(ticket.responsible));
+ }
+
public boolean canReviewPatchset(RepositoryModel model) {
- return isAuthenticated && canClone(model);
+ return isAuthenticated() && canClone(model);
}
public boolean canApprovePatchset(RepositoryModel model) {
- return isAuthenticated && canPush(model);
+ return isAuthenticated() && canPush(model);
}
public boolean canVetoPatchset(RepositoryModel model) {
- return isAuthenticated && canPush(model);
+ return isAuthenticated() && canPush(model);
}
/**
@@ -529,7 +543,7 @@
// admins can create any repository
return true;
}
- if (canCreate) {
+ if (canCreate()) {
String projectPath = StringUtils.getFirstPathElement(repository);
if (!StringUtils.isEmpty(projectPath) && projectPath.equalsIgnoreCase(getPersonalPath())) {
// personal repository
@@ -539,6 +553,20 @@
return false;
}
+ /**
+ * Returns true if the user is allowed to administer the specified repository
+ *
+ * @param repo
+ * @return true if the user can administer the repository
+ */
+ public boolean canAdmin(RepositoryModel repo) {
+ return canAdmin() || repo.isOwner(username) || isMyPersonalRepository(repo.name);
+ }
+
+ public boolean isAuthenticated() {
+ return !UserModel.ANONYMOUS.equals(this) && isAuthenticated;
+ }
+
public boolean isTeamMember(String teamname) {
for (TeamModel team : teams) {
if (team.name.equalsIgnoreCase(teamname)) {
--
Gitblit v1.9.1