Adding warden scopes to helper methods.

This commit is contained in:
Carlos A. da Silva
2009-10-10 16:47:11 -03:00
parent 4e263b96c9
commit 561833e060
4 changed files with 25 additions and 16 deletions

View File

@@ -24,33 +24,33 @@ module Devise
# Proxy to the authenticated? method on warden
#
def authenticated?(*args)
warden.authenticated?(*args)
def authenticated?(scope=resource_name)
warden.authenticated?(scope)
end
alias_method :logged_in?, :authenticated?
# Access the currently logged in user
#
def user(*args)
warden.user(*args)
def user
warden.user(resource_name)
end
alias_method :current_user, :user
def user=(user)
warden.set_user user
warden.set_user(user, :scope => resource_name)
end
alias_method :current_user=, :user=
# Logout the current user
#
def logout(*args)
def logout
warden.raw_session.inspect # Without this inspect here. The session does not clear :|
warden.logout(*args)
warden.logout(resource_name)
end
# Verify authenticated user and redirect to sign in if no authentication is found
#
def authenticate!(*args)
def authenticate!
redirect_to new_session_path unless authenticated?
end