Commit 51b29cd

mo <mo.khan@gmail.com>
2017-12-22 00:19:29
render a blank dashboard post login.
1 parent 83ceba9
app/controllers/dashboards_controller.rb
@@ -0,0 +1,4 @@
+class DashboardsController < ApplicationController
+  def show
+  end
+end
app/controllers/sessions_controller.rb
@@ -18,6 +18,8 @@ class SessionsController < ApplicationController
 
   def create
     if user = User.login(user_params[:email], user_params[:password])
+      return redirect_to(dashboard_path) unless session[:saml].present?
+
       binding = idp.single_sign_on_service_for(binding: session[:saml][:binding])
       saml_request = binding.deserialize(session[:saml][:params])
       return render_error(:forbidden, model: saml_request) if saml_request.invalid?
app/views/dashboards/show.html.erb
@@ -0,0 +1,7 @@
+<div class="container">
+  <div class="row">
+    <div class="col">
+      <h1>Dashboard</h1>
+    </div>
+  </div>
+</div>
config/routes.rb
@@ -4,5 +4,6 @@ Rails.application.routes.draw do
   post "/session/logout" => "sessions#destroy", as: :logout
   post "/session/new" => "sessions#new"
   resource :metadata, only: [:show]
+  resource :dashboard, only: [:show]
   root to: "sessions#new"
 end
spec/requests/sessions_controller_spec.rb
@@ -73,4 +73,15 @@ describe SessionsController do
       end
     end
   end
+
+  describe "#create" do
+    let(:user) { User.create!(email: FFaker::Internet.email, password: password) }
+    let(:password) { FFaker::Internet.password }
+
+    it 'redirects to the dashboard when a SAMLRequest is not present' do
+      post '/session', params: { user: { email: user.email, password: password } }
+
+      expect(response).to redirect_to('/dashboard')
+    end
+  end
 end