Skip to content
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.

Commit

Permalink
Support logout
Browse files Browse the repository at this point in the history
  • Loading branch information
kmcphillips committed Sep 20, 2013
1 parent c1cb482 commit 555303d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion 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'
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -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
5 changes: 5 additions & 0 deletions lib/google_auth/controller.rb
Expand Up @@ -19,5 +19,10 @@ def ensure_authenticated
end
end

def logout
session[:user_id] = nil
@current_user = nil
end

end
end

0 comments on commit 555303d

Please sign in to comment.