From 8d96b960e472433d2b4a5b71df7000bf1fbde648 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Thu, 10 Apr 2014 18:58:10 -0400 Subject: [PATCH] Track the SSH public key used for a session and add a `keys which` command --- src/main/java/com/gitblit/models/UserModel.java | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/gitblit/models/UserModel.java b/src/main/java/com/gitblit/models/UserModel.java index 6419cce..675835d 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,6 +447,31 @@ 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); + } + + public boolean canApprovePatchset(RepositoryModel model) { + return isAuthenticated() && canPush(model); + } + + public boolean canVetoPatchset(RepositoryModel model) { + return isAuthenticated() && canPush(model); + } + /** * This returns true if the user has fork privileges or the user has fork * privileges because of a team membership. @@ -527,6 +553,10 @@ return false; } + 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