mirror of
https://github.com/heartcombo/devise.git
synced 2026-04-28 03:00:29 -04:00
Adding warden scopes to helper methods.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user