]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/concerns/session_methods.rb
Make blank role icons transparent
[rails.git] / app / controllers / concerns / session_methods.rb
index cebe932fc9862fae21c1cfdb13d93ffa82b4cd46..5dcddb82debb5e4849039c28e2d4cf128d6f5c5f 100644 (file)
@@ -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)