Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrickatamaniuk/2758024 to your computer and use it in GitHub Desktop.
Save patrickatamaniuk/2758024 to your computer and use it in GitHub Desktop.
redmine REST api session hack
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 734b2d8..a89a4a4 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -105,7 +105,9 @@ class ApplicationController < ActionController::Base
elsif Setting.rest_api_enabled? && accept_api_auth?
if (key = api_key_from_request)
# Use API key
- User.find_by_api_key(key)
+ user = User.find_by_api_key(key)
+ session[:user_id] = user.id if user
+ user
else
# HTTP Basic, either username/password or API key/random
authenticate_with_http_basic do |username, password|
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment