Browse Source

Make manual logout work

Maarten van den Berg 8 years ago
parent
commit
a9c84de033

+ 3 - 2
app/controllers/authentication_controller.rb

@@ -1,4 +1,5 @@
1 1
 class AuthenticationController < ApplicationController
2
+  before_action :require_login!, only: [:logout_confirm, :logout]
2 3
   def login_form
3 4
     render layout: 'void'
4 5
   end
@@ -14,7 +15,7 @@ class AuthenticationController < ApplicationController
14 15
         log_in(u, params[:session][:remember_me].to_i)
15 16
 
16 17
         flash[:success] = "Hello, #{u.person.full_name}!"
17
-        redirect_to dashboard_home_path
18
+        redirect_to root_path
18 19
       else
19 20
         flash[:danger] = "Invalid username/password combination!"
20 21
         redirect_to action: 'login_form'
@@ -22,7 +23,7 @@ class AuthenticationController < ApplicationController
22 23
     end
23 24
   end
24 25
 
25
-  def logout_form
26
+  def logout_confirm
26 27
     render layout: 'void'
27 28
   end
28 29
 

+ 10 - 0
app/views/authentication/logout_confirm.html.haml

@@ -0,0 +1,10 @@
1
+.container
2
+  .panel.panel-default
3
+    .panel-heading
4
+      Are you sure?
5
+    .panel-body
6
+      = link_to logout_path, method: :delete, class: 'btn btn-danger' do
7
+        %i.fa.fa-sign-out{'aria-hidden': true}
8
+        Log out
9
+      = link_to root_path, class: 'btn btn-default' do
10
+        Cancel