Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support logout

  • Loading branch information...
commit 555303d941a5128dbf5a15d06d13b95b76c5dd81 1 parent c1cb482
@kmcphillips kmcphillips authored
View
7 app/controllers/sessions_controller.rb
@@ -1,6 +1,6 @@
class SessionsController < ApplicationController
skip_before_filter :ensure_authenticated
- protect_from_forgery except: [:new, :create, :failure]
+ protect_from_forgery except: [:new, :create, :failure, :destroy]
def new
redirect_to '/auth/g'
@@ -20,6 +20,11 @@ def create
end
end
+ def destroy
+ logout
+ redirect_to root_path
+ end
+
def failure
render :inline => 'Snowman says no. <div id="snowman" style="text-align:center; font-size:4000%;">&#9731;</div>'
end
View
1  config/routes.rb
@@ -2,4 +2,5 @@
get '/login', :to => 'sessions#new', :as => :login
post '/auth/g/callback', :to => 'sessions#create'
post '/auth/failure', :to => 'sessions#failure'
+ delete '/logout', :to => 'sessions#destroy', :as => :logout
end
View
5 lib/google_auth/controller.rb
@@ -19,5 +19,10 @@ def ensure_authenticated
end
end
+ def logout
+ session[:user_id] = nil
+ @current_user = nil
+ end
+
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.