From 6d23cab9f5387ca2b57f60b26936ff8af0acc8fa Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Fri, 19 Oct 2012 22:45:30 -0400 Subject: [PATCH] Added UserModel null check --- src/com/gitblit/RpcServlet.java | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/com/gitblit/RpcServlet.java b/src/com/gitblit/RpcServlet.java index 115d553..2a6ba26 100644 --- a/src/com/gitblit/RpcServlet.java +++ b/src/com/gitblit/RpcServlet.java @@ -49,7 +49,7 @@ private static final long serialVersionUID = 1L; - public static final int PROTOCOL_VERSION = 2; + public static final int PROTOCOL_VERSION = 4; public RpcServlet() { super(); @@ -73,10 +73,10 @@ UserModel user = (UserModel) request.getUserPrincipal(); - boolean allowManagement = user != null && user.canAdmin + boolean allowManagement = user != null && user.canAdmin() && GitBlit.getBoolean(Keys.web.enableRpcManagement, false); - boolean allowAdmin = user != null && user.canAdmin + boolean allowAdmin = user != null && user.canAdmin() && GitBlit.getBoolean(Keys.web.enableRpcAdministration, false); Object result = null; @@ -298,6 +298,9 @@ for (String key : keys) { managementSettings.add(settings.get(key)); } + if (allowManagement) { + managementSettings.pushScripts = settings.pushScripts; + } result = managementSettings; } } else if (RpcRequest.EDIT_SETTINGS.equals(reqType)) { @@ -316,6 +319,13 @@ } else { response.sendError(notAllowedCode); } + } else if (RpcRequest.CLEAR_REPOSITORY_CACHE.equals(reqType)) { + // clear the repository list cache + if (allowManagement) { + GitBlit.self().resetRepositoryListCache(); + } else { + response.sendError(notAllowedCode); + } } // send the result of the request -- Gitblit v1.9.1