Class: User
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- User
- Defined in:
- app/models/user.rb
Instance Attribute Summary collapse
-
#skip_password_validation ⇒ Object
Returns the value of attribute skip_password_validation.
Instance Method Summary collapse
- #admin? ⇒ Boolean
- #content_editor? ⇒ Boolean
- #designer? ⇒ Boolean
- #has_role?(role) ⇒ Boolean
- #locale ⇒ Object
- #name ⇒ Object
- #password_complexity ⇒ Object
- #password_required? ⇒ Boolean
Instance Attribute Details
#skip_password_validation ⇒ Object
Returns the value of attribute skip_password_validation.
11 12 13 |
# File 'app/models/user.rb', line 11 def skip_password_validation @skip_password_validation end |
Instance Method Details
#admin? ⇒ Boolean
35 36 37 |
# File 'app/models/user.rb', line 35 def admin? admin end |
#content_editor? ⇒ Boolean
43 44 45 |
# File 'app/models/user.rb', line 43 def content_editor? content_editor end |
#designer? ⇒ Boolean
39 40 41 |
# File 'app/models/user.rb', line 39 def designer? designer end |
#has_role?(role) ⇒ Boolean
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/models/user.rb', line 22 def has_role?(role) case role when :admin admin? when :designer designer? when :content_editor content_editor? else false end end |
#locale ⇒ Object
47 48 49 |
# File 'app/models/user.rb', line 47 def locale 'en' end |
#name ⇒ Object
51 52 53 |
# File 'app/models/user.rb', line 51 def name "#{first_name} #{last_name}" end |
#password_complexity ⇒ Object
61 62 63 64 65 |
# File 'app/models/user.rb', line 61 def password_complexity return false if password.blank? || password =~ /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,70}$/ errors.add :password, 'Complexity requirement not met. Length should be 12 characters and include: 1 uppercase, 1 lowercase, 1 digit and 1 special character.' end |
#password_required? ⇒ Boolean
55 56 57 58 59 |
# File 'app/models/user.rb', line 55 def password_required? return false if skip_password_validation super end |