lib/devise/models/authenticable.rb in devise-0.1.1 vs lib/devise/models/authenticable.rb in devise-0.2.0
- old
+ new
@@ -1,6 +1,7 @@
require 'digest/sha1'
+require 'devise/strategies/authenticable'
module Devise
module Models
# Authenticable Module, responsible for encrypting password and validating
@@ -22,20 +23,16 @@
#
# User.authenticate('email@test.com', 'password123') # returns authenticated user or nil
# User.find(1).valid_password?('password123') # returns true/false
#
module Authenticable
- Devise.model_config(self, :pepper)
- Devise.model_config(self, :stretches, 10)
-
def self.included(base)
base.class_eval do
extend ClassMethods
attr_reader :password
attr_accessor :password_confirmation
- attr_accessible :email, :password, :password_confirmation
end
end
# Regenerates password salt and encrypted password each time password is
# setted.
@@ -72,11 +69,10 @@
def friendly_token
ActiveSupport::SecureRandom.base64(15).tr('+/=', '-_ ').strip.delete("\n")
end
module ClassMethods
-
# Authenticate a user based on email and password. Returns the
# authenticated user if it's valid or nil.
# Attributes are :email and :password
def authenticate(attributes={})
authenticable = find_by_email(attributes[:email])
@@ -91,8 +87,11 @@
perishable.errors.add(:email, :not_found, :default => 'not found')
end
perishable
end
end
+
+ Devise.model_config(self, :pepper)
+ Devise.model_config(self, :stretches, 10)
end
end
end