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
- #editor? ⇒ Boolean
- #locale ⇒ Object
- #name ⇒ Object
- #password_complexity ⇒ Object
- #password_required? ⇒ Boolean
-
#role?(role) ⇒ Boolean
Roles Admin - all permissions Editor - all permissions except for users, sites editing Content Editor - all permissions except for users, sites, publishing and deleting.
- #scoped_site? ⇒ Boolean
Instance Attribute Details
#skip_password_validation ⇒ Object
Returns the value of attribute skip_password_validation.
10 11 12 |
# File 'app/models/user.rb', line 10 def skip_password_validation @skip_password_validation end |
Instance Method Details
#admin? ⇒ Boolean
41 42 43 |
# File 'app/models/user.rb', line 41 def admin? admin end |
#content_editor? ⇒ Boolean
53 54 55 |
# File 'app/models/user.rb', line 53 def content_editor? content_editor end |
#designer? ⇒ Boolean
45 46 47 |
# File 'app/models/user.rb', line 45 def designer? designer end |
#editor? ⇒ Boolean
49 50 51 |
# File 'app/models/user.rb', line 49 def editor? designer end |
#locale ⇒ Object
61 62 63 |
# File 'app/models/user.rb', line 61 def locale 'en' end |
#name ⇒ Object
65 66 67 |
# File 'app/models/user.rb', line 65 def name "#{first_name} #{last_name}" end |
#password_complexity ⇒ Object
75 76 77 78 79 |
# File 'app/models/user.rb', line 75 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
69 70 71 72 73 |
# File 'app/models/user.rb', line 69 def password_required? return false if skip_password_validation super end |
#role?(role) ⇒ Boolean
Roles Admin - all permissions Editor - all permissions except for users, sites editing Content Editor - all permissions except for users, sites, publishing and deleting
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/models/user.rb', line 28 def role?(role) case role when :admin admin? when :designer designer? when :content_editor content_editor? else false end end |
#scoped_site? ⇒ Boolean
57 58 59 |
# File 'app/models/user.rb', line 57 def scoped_site? sites.present? end |