mirror of
https://github.com/heartcombo/devise.git
synced 2026-04-28 03:00:29 -04:00
Updating sessions controller to use resource oriented style. Changing authenticate method to accept a hash of attributes.
This commit is contained in:
@@ -82,11 +82,12 @@ module Devise
|
||||
module ClassMethods
|
||||
|
||||
# Authenticate a user based on email and password. Returns the
|
||||
# authenticated user if it's valid or nil
|
||||
# authenticated user if it's valid or nil.
|
||||
# Attributes are :email and :password
|
||||
#
|
||||
def authenticate(email, password)
|
||||
authenticable = self.find_by_email(email)
|
||||
authenticable if authenticable.valid_password?(password) unless authenticable.nil?
|
||||
def authenticate(attributes={})
|
||||
authenticable = self.find_by_email(attributes[:email])
|
||||
authenticable if authenticable.valid_password?(attributes[:password]) unless authenticable.nil?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -81,7 +81,7 @@ module Devise
|
||||
# Hook default authenticate to test whether the account is confirmed or not
|
||||
# Returns the authenticated_user if it's confirmed, otherwise returns nil
|
||||
#
|
||||
def authenticate(email, password)
|
||||
def authenticate(attributes={})
|
||||
confirmable = super
|
||||
confirmable if confirmable.confirmed? unless confirmable.nil?
|
||||
end
|
||||
@@ -91,8 +91,8 @@ module Devise
|
||||
# with an email not found error.
|
||||
# Options must contain the user email
|
||||
#
|
||||
def send_confirmation_instructions(options={})
|
||||
confirmable = find_or_initialize_with_error_by_email(options[:email])
|
||||
def send_confirmation_instructions(attributes={})
|
||||
confirmable = find_or_initialize_with_error_by_email(attributes[:email])
|
||||
confirmable.reset_confirmation! unless confirmable.new_record?
|
||||
confirmable
|
||||
end
|
||||
@@ -102,8 +102,8 @@ module Devise
|
||||
# If the user is already confirmed, create an error for the user
|
||||
# Options must have the perishable_token
|
||||
#
|
||||
def confirm!(options={})
|
||||
confirmable = find_or_initialize_with_error_by_perishable_token(options[:perishable_token])
|
||||
def confirm!(attributes={})
|
||||
confirmable = find_or_initialize_with_error_by_perishable_token(attributes[:perishable_token])
|
||||
confirmable.confirm! unless confirmable.new_record?
|
||||
confirmable
|
||||
end
|
||||
|
||||
@@ -48,10 +48,10 @@ module Devise
|
||||
# Attempt to find a user by it's email. If a record is found, send new
|
||||
# password instructions to it. If not user is found, returns a new user
|
||||
# with an email not found error.
|
||||
# Options must contain the user email
|
||||
# Attributes must contain the user email
|
||||
#
|
||||
def send_reset_password_instructions(options={})
|
||||
recoverable = find_or_initialize_with_error_by_email(options[:email])
|
||||
def send_reset_password_instructions(attributes={})
|
||||
recoverable = find_or_initialize_with_error_by_email(attributes[:email])
|
||||
recoverable.send_reset_password_instructions unless recoverable.new_record?
|
||||
recoverable
|
||||
end
|
||||
@@ -60,11 +60,11 @@ module Devise
|
||||
# If a user is found, reset it's password and automatically try saving the
|
||||
# record. If not user is found, returns a new user containing an error
|
||||
# in perishable_token attribute.
|
||||
# Options must contain perishable_token, password and confirmation
|
||||
# Attributes must contain perishable_token, password and confirmation
|
||||
#
|
||||
def reset_password!(options={})
|
||||
recoverable = find_or_initialize_with_error_by_perishable_token(options[:perishable_token])
|
||||
recoverable.reset_password!(options[:password], options[:password_confirmation]) unless recoverable.new_record?
|
||||
def reset_password!(attributes={})
|
||||
recoverable = find_or_initialize_with_error_by_perishable_token(attributes[:perishable_token])
|
||||
recoverable.reset_password!(attributes[:password], attributes[:password_confirmation]) unless recoverable.new_record?
|
||||
recoverable
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user