Module: Typus::Orm::ActiveRecord::AdminUserV2::InstanceMethods
- Defined in:
- lib/typus/orm/active_record/admin_user_v2.rb
Instance Method Summary collapse
- #authenticate(unencrypted_password) ⇒ Object
- #locale ⇒ Object
- #locale=(locale) ⇒ Object
- #password=(unencrypted_password) ⇒ Object
- #password_must_be_strong(count = 6) ⇒ Object
- #to_label ⇒ Object
Instance Method Details
#authenticate(unencrypted_password) ⇒ Object
59 60 61 62 |
# File 'lib/typus/orm/active_record/admin_user_v2.rb', line 59 def authenticate(unencrypted_password) equal = BCrypt::Password.new(password_digest) == unencrypted_password equal ? self : false end |
#locale ⇒ Object
50 51 52 |
# File 'lib/typus/orm/active_record/admin_user_v2.rb', line 50 def locale (preferences && preferences[:locale]) ? preferences[:locale] : ::I18n.default_locale end |
#locale=(locale) ⇒ Object
54 55 56 57 |
# File 'lib/typus/orm/active_record/admin_user_v2.rb', line 54 def locale=(locale) self.preferences ||= {} self.preferences[:locale] = locale end |
#password=(unencrypted_password) ⇒ Object
64 65 66 67 |
# File 'lib/typus/orm/active_record/admin_user_v2.rb', line 64 def password=(unencrypted_password) @password = unencrypted_password self.password_digest = BCrypt::Password.create(unencrypted_password) end |
#password_must_be_strong(count = 6) ⇒ Object
69 70 71 72 73 |
# File 'lib/typus/orm/active_record/admin_user_v2.rb', line 69 def password_must_be_strong(count = 6) if password.present? && password.size < count errors.add(:password, :too_short, :count => count) end end |
#to_label ⇒ Object
45 46 47 48 |
# File 'lib/typus/orm/active_record/admin_user_v2.rb', line 45 def to_label full_name = [first_name, last_name].delete_if { |s| s.blank? } full_name.any? ? full_name.join(" ") : email end |