X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/12c1d5e6c05813a0697724277b4d8529a1a7c240..9649b192c03f7a333f3a02697a64910cd6669dab:/app/controllers/concerns/session_methods.rb?ds=sidebyside diff --git a/app/controllers/concerns/session_methods.rb b/app/controllers/concerns/session_methods.rb index fca851eeb..5dcddb82d 100644 --- a/app/controllers/concerns/session_methods.rb +++ b/app/controllers/concerns/session_methods.rb @@ -3,6 +3,18 @@ module SessionMethods private + ## + # Read @preferred_auth_provider and @client_app_name from oauth2 authorization request's referer + def parse_oauth_referer(referer) + referer_query = URI(referer).query if referer + return unless referer_query + + ref_params = CGI.parse referer_query + preferred = ref_params["preferred_auth_provider"].first + @preferred_auth_provider = preferred if preferred && Settings.key?(:"#{preferred}_auth_id") + @client_app_name = Oauth2Application.where(:uid => ref_params["client_id"].first).pick(:name) + end + ## # return the URL to use for authentication def auth_url(provider, uid, referer = nil) @@ -62,9 +74,10 @@ module SessionMethods ## # def unconfirmed_login(user) - session[:token] = user.tokens.create.token + session[:pending_user] = user.id - redirect_to :controller => "confirmations", :action => "confirm", :display_name => user.display_name + redirect_to :controller => "confirmations", :action => "confirm", + :display_name => user.display_name, :referer => session[:referer] session.delete(:remember_me) session.delete(:referer)