Module: Huberry::Authentication::ModelMethods
- Defined in:
- lib/huberry/authentication/model_methods.rb
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Instance Method Summary collapse
Instance Method Details
#uses_authentication(options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/huberry/authentication/model_methods.rb', line 6 def uses_authentication( = {}) extend ClassMethods include InstanceMethods cattr_accessor :authentication_options self. = { :hashed_password_field => :hashed_password, :login_field => :email, :password_field => :password, :salt_field => :salt }.merge() attr_accessor self.[:password_field], "#{self.[:password_field]}_confirmation".to_sym validates_presence_of self.[:login_field] validates_presence_of self.[:password_field], :if => :password_required? validates_confirmation_of self.[:password_field], :if => :password_required? before_save :hash_password alias_method_chain :reload, :authentication end |