From ddcebbd982d81dabf8cb1c89f60f9b876a23b58c Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Thu, 04 Sep 2014 13:32:44 -0400 Subject: [PATCH] Merged #149 "Repo creation with initial commit fails if user does not have an email address" --- src/main/java/com/gitblit/auth/RedmineAuthProvider.java | 19 +++++++------------ 1 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/gitblit/auth/RedmineAuthProvider.java b/src/main/java/com/gitblit/auth/RedmineAuthProvider.java index 176c576..e505a54 100644 --- a/src/main/java/com/gitblit/auth/RedmineAuthProvider.java +++ b/src/main/java/com/gitblit/auth/RedmineAuthProvider.java @@ -26,7 +26,6 @@ import com.gitblit.Keys; import com.gitblit.auth.AuthenticationProvider.UsernamePasswordAuthenticationProvider; import com.gitblit.models.UserModel; -import com.gitblit.utils.ArrayUtils; import com.gitblit.utils.ConnectionUtils; import com.gitblit.utils.StringUtils; import com.google.gson.Gson; @@ -122,24 +121,19 @@ } UserModel user = userManager.getUserModel(username); - if (user == null) // create user object for new authenticated user + if (user == null) { + // create user object for new authenticated user user = new UserModel(username.toLowerCase()); + } // create a user cookie - if (StringUtils.isEmpty(user.cookie) && !ArrayUtils.isEmpty(password)) { - user.cookie = StringUtils.getSHA1(user.username + new String(password)); - } + setCookie(user, password); // update user attributes from Redmine user.accountType = getAccountType(); user.displayName = current.user.firstname + " " + current.user.lastname; user.emailAddress = current.user.mail; user.password = Constants.EXTERNAL_ACCOUNT; - if (!StringUtils.isEmpty(current.user.login)) { - // only admin users can get login name - // evidently this is an undocumented behavior of Redmine - user.canAdmin = true; - } // TODO consider Redmine group mapping for team membership // http://www.redmine.org/projects/redmine/wiki/Rest_Users @@ -159,15 +153,16 @@ if (!url.endsWith("/")) { url = url.concat("/"); } + String apiUrl = url + "users/current.json"; + HttpURLConnection http; if (username == null) { // apikey authentication String apiKey = String.valueOf(password); - String apiUrl = url + "users/current.json?key=" + apiKey; http = (HttpURLConnection) ConnectionUtils.openConnection(apiUrl, null, null); + http.addRequestProperty("X-Redmine-API-Key", apiKey); } else { // username/password BASIC authentication - String apiUrl = url + "users/current.json"; http = (HttpURLConnection) ConnectionUtils.openConnection(apiUrl, username, password); } http.setRequestMethod("GET"); -- Gitblit v1.9.1