Commit 5c34b44

mo <mo.khan@gmail.com>
2018-09-09 21:34:02
move _response template to responses folder.
1 parent 7a54910
app/controllers/responses_controller.rb
@@ -3,11 +3,9 @@
 class ResponsesController < ApplicationController
   def show
     if session[:saml].present?
-      saml_request = Saml::Kit::AuthenticationRequest.new(session[:saml][:xml])
-      if saml_request.invalid?
-        return render_error(:forbidden, model: saml_request)
-      end
-      post_back(saml_request)
+      saml = Saml::Kit::AuthenticationRequest.new(session[:saml][:xml])
+      return render_error(:forbidden, model: saml) if saml.invalid?
+      post_back(saml, session[:saml][:params][:RelayState])
     else
       redirect_to my_dashboard_path
     end
@@ -15,13 +13,11 @@ class ResponsesController < ApplicationController
 
   private
 
-  def post_back(saml_request)
-    relay_state = session[:saml][:params][:RelayState]
-    @url, @saml_params = saml_request.response_for(
+  def post_back(saml, relay_state)
+    @url, @saml_params = saml.response_for(
       current_user, binding: :http_post, relay_state: relay_state
     ) do |builder|
       @saml_response_builder = builder
     end
-    render template: 'sessions/create'
   end
 end
app/views/sessions/_response.html.erb → app/views/responses/_response.html.erb
File renamed without changes
app/views/responses/show.html.erb
@@ -0,0 +1,1 @@
+<%= render partial: "response" %>
app/views/sessions/create.html.erb
@@ -1,1 +0,0 @@
-<%= render partial: "sessions/response" %>
app/views/sessions/destroy.html.erb
@@ -1,1 +1,1 @@
-<%= render partial: "response" %>
+<%= render partial: "responses/response" %>