Allow logging out even if you are not logged in
This commit is contained in:
parent
737ff62cfc
commit
ddeb49c672
1 changed files with 6 additions and 2 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
class UserSessionsController < ApplicationController
|
class UserSessionsController < ApplicationController
|
||||||
|
|
||||||
|
# before_filter :require_user, :only => :destroy
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@user_session = UserSession.new
|
@user_session = UserSession.new
|
||||||
end
|
end
|
||||||
|
|
@ -15,8 +17,10 @@ class UserSessionsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
current_user_session.destroy
|
if current_user
|
||||||
flash[:notice] = "Logout successful!"
|
current_user_session.destroy
|
||||||
|
flash[:notice] = "Logout successful!"
|
||||||
|
end
|
||||||
redirect_back_or_default new_user_session_url
|
redirect_back_or_default new_user_session_url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue