summaryrefslogtreecommitdiffstats
path: root/src/com/gitblit/models/UserModel.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/gitblit/models/UserModel.java')
-rw-r--r--src/com/gitblit/models/UserModel.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/com/gitblit/models/UserModel.java b/src/com/gitblit/models/UserModel.java
index fc9cbfba..7995f7e4 100644
--- a/src/com/gitblit/models/UserModel.java
+++ b/src/com/gitblit/models/UserModel.java
@@ -364,6 +364,28 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
}
return false;
}
+
+ /**
+ * Returns true if the user is allowed to create the specified repository
+ * on-push if the repository does not already exist.
+ *
+ * @param repository
+ * @return true if the user can create the repository
+ */
+ public boolean canCreateOnPush(String repository) {
+ if (canAdmin()) {
+ // admins can create any repository
+ return true;
+ }
+ if (canCreate) {
+ String projectPath = StringUtils.getFirstPathElement(repository);
+ if (!StringUtils.isEmpty(projectPath) && projectPath.equalsIgnoreCase("~" + username)) {
+ // personal repository
+ return true;
+ }
+ }
+ return false;
+ }
public boolean isTeamMember(String teamname) {
for (TeamModel team : teams) {