| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | 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 |