mirror of
https://github.com/heartcombo/devise.git
synced 2026-04-28 03:00:29 -04:00
Refactoring.
This commit is contained in:
@@ -74,8 +74,8 @@ module Devise
|
||||
# authenticated user if it's valid or nil
|
||||
#
|
||||
def authenticate(email, password)
|
||||
user = self.find_by_email(email)
|
||||
user if user.valid_password?(password) unless user.nil?
|
||||
authenticable = self.find_by_email(email)
|
||||
authenticable if authenticable.valid_password?(password) unless authenticable.nil?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -41,13 +41,13 @@ module Devise
|
||||
# If no user is found, returns a new user
|
||||
# If the user is already confirmed, create an error for the user
|
||||
def find_and_confirm(confirmation_token)
|
||||
user = find_or_initialize_by_confirmation_token(confirmation_token)
|
||||
unless user.new_record?
|
||||
user.confirm!
|
||||
confirmable = find_or_initialize_by_confirmation_token(confirmation_token)
|
||||
unless confirmable.new_record?
|
||||
confirmable.confirm!
|
||||
else
|
||||
user.errors.add(:confirmation_token, :invalid, :default => "invalid confirmation")
|
||||
confirmable.errors.add(:confirmation_token, :invalid, :default => "invalid confirmation")
|
||||
end
|
||||
user
|
||||
confirmable
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user