Created
November 27, 2010 00:04
-
-
Save keo/717371 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.included(base) | |
@user_models << base.name | |
base.extend(ClassMethods) | |
base.class_eval do | |
fields do | |
crypted_password :string, :limit => 40 | |
salt :string, :limit => 40 | |
remember_token :string | |
remember_token_expires_at :datetime | |
end | |
validates_confirmation_of :password, :if => :new_password_required? | |
password_validations | |
validate :validate_current_password_when_changing_password | |
# Virtual attributes for setting and changing the password | |
# note that :password_confirmation= is also defined by | |
# validates_confirmation_of, so this line must follow any | |
# validates_confirmation_of statements. | |
# https://hobo.lighthouseapp.com/projects/8324-hobo/tickets/530 | |
attr_accessor :current_password, :password, :password_confirmation, :type => :password | |
before_save :encrypt_password | |
after_save :stash_current_password | |
never_show *AUTHENTICATION_FIELDS | |
attr_protected *AUTHENTICATION_FIELDS | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment