X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/7058d836f75c845b7790c7ab6eb2f75844ce0c1c..1ffb5c1502d870a1d1c46648ea0c165e25dfbef9:/app/controllers/application.rb diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 579c50e95..f5ea0063d 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -22,7 +22,11 @@ class ApplicationController < ActionController::Base redirect_to :controller => 'user', :action => 'login', :referer => request.request_uri unless @user end - def authorize(realm='Web Password', errormessage="Couldn't authenticate you") + ## + # sets up the @user object for use by other methods. this is mostly called + # from the authorize method, but can be called elsewhere if authorisation + # is optional. + def setup_user_auth username, passwd = get_auth_data # parse from headers # authenticate per-scheme if username.nil? @@ -32,6 +36,11 @@ class ApplicationController < ActionController::Base else @user = User.authenticate(:username => username, :password => passwd) # basic auth end + end + + def authorize(realm='Web Password', errormessage="Couldn't authenticate you") + # make the @user object from any auth sources we have + setup_user_auth # handle authenticate pass/fail unless @user