This is an automated email from the git hooks/post-receive script. New commit to annotated tag v1.7 in repository jredmine. See https://gitlab.nuiton.org/nuiton/jredmine.git commit 22b29eae4e71254fc17f7ea7ba7e1ce9c9a140b4 Author: Tony Chemit <chemit@codelutin.com> Date: Wed Apr 16 09:40:31 2014 +0000 refs #3151 (fix old login way) --- .../app/controllers/jredmine_controller.rb | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/jredmine-client/src/main/redmine/jredmine-2.x/app/controllers/jredmine_controller.rb b/jredmine-client/src/main/redmine/jredmine-2.x/app/controllers/jredmine_controller.rb index dc3c707..46b0973 100644 --- a/jredmine-client/src/main/redmine/jredmine-2.x/app/controllers/jredmine_controller.rb +++ b/jredmine-client/src/main/redmine/jredmine-2.x/app/controllers/jredmine_controller.rb @@ -54,6 +54,7 @@ class JredmineController < ActionController::Base end # Login request and validation + # Deprecated since 1.7, will be removed in version 2.0 def login if !request.post? # Logout user : get method not possible @@ -81,6 +82,7 @@ class JredmineController < ActionController::Base end # Log out current user and redirect to welcome page + # Deprecated since 1.7, will be removed in version 2.0 def logout cookies.delete :autologin Token.delete_all(["user_id = ? AND action = ?", User.current.id, 'autologin']) if User.current.logged? @@ -488,6 +490,35 @@ class JredmineController < ActionController::Base User.current = user end + # Returns the current user or nil if no user is logged in + # Deprecated since 1.7, will be removed in version 2.0 + def find_current_user + user = nil + if session[:user_id] + # existing session + user = (User.active.find(session[:user_id]) rescue nil) + elsif cookies[:autologin] + # auto-login feature + user = User.find_by_autologin_key(cookies[:autologin]) + end + if user.nil? && Setting.rest_api_enabled? + if (key = api_key_from_request) + # Use API key + user = User.find_by_api_key(key) + else + # HTTP Basic, either username/password or API key/random + authenticate_with_http_basic do |username, password| + user = User.try_to_login(username, password) || User.find_by_api_key(username) + end + end + end + if user.nil? + # Last chance using request params + user = User.try_to_login(params[:username], params[:password]) + end + user + end + # Returns the API key present in the request def api_key_from_request if params[:key].present? -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.