Module: Minimalist::Authentication
- Defined in:
- lib/minimalist/authentication.rb
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Constant Summary collapse
- GUEST_USER_EMAIL =
'guest'
- PREFERRED_DIGEST_VERSION =
3
- CALIBRATED_BCRYPT_COST =
Recalibrates cost when class is loaded so that new user passwords can automatically take advantage of faster server hardware in the future for better encryption.
BCrypt::Engine.calibrate(750)
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/minimalist/authentication.rb', line 14 def self.included( base ) base.extend(ClassMethods) base.class_eval do include InstanceMethods attr_accessor :password before_save :encrypt_password validates_presence_of :email, :if => :validate_email_presence? validates_uniqueness_of :email, :if => :validate_email_uniqueness? validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i, :if => :validate_email_format? validates_presence_of :password, :if => :password_required? validates_confirmation_of :password, :if => :password_required? validates_length_of :password, :within => 6..40, :if => :password_required? scope :active, :conditions => {:active => true} end end |