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.
Class Method Summary collapse
-
.serialize_from_session(key, salt) ⇒ Object
Observe-only instrument for the intermittent logout bug (issue #1040).
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.
12 13 14 |
# File 'app/models/user.rb', line 12 def skip_password_validation @skip_password_validation end |
Class Method Details
.serialize_from_session(key, salt) ⇒ Object
Observe-only instrument for the intermittent logout bug (issue #1040). This keeps Devise's exact (site-scoped) behavior — it returns the scoped lookup unchanged, so a mismatch still logs the user out exactly as before — and only reports when a valid user was excluded by the site scope. See TrustyCms::SiteScopeAuthReporter. The behavior-change fix is separate (PR #1041).
88 89 90 91 92 |
# File 'app/models/user.rb', line 88 def self.serialize_from_session(key, salt) record = to_adapter.get(key) TrustyCms::SiteScopeAuthReporter.report_miss(key) if record.nil? record if record && record.authenticatable_salt == salt end |
Instance Method Details
#admin? ⇒ Boolean
43 44 45 |
# File 'app/models/user.rb', line 43 def admin? admin end |
#content_editor? ⇒ Boolean
55 56 57 |
# File 'app/models/user.rb', line 55 def content_editor? content_editor end |
#designer? ⇒ Boolean
47 48 49 |
# File 'app/models/user.rb', line 47 def designer? designer end |
#editor? ⇒ Boolean
51 52 53 |
# File 'app/models/user.rb', line 51 def editor? designer end |
#locale ⇒ Object
63 64 65 |
# File 'app/models/user.rb', line 63 def locale 'en' end |
#name ⇒ Object
67 68 69 |
# File 'app/models/user.rb', line 67 def name "#{first_name} #{last_name}" end |
#password_complexity ⇒ Object
77 78 79 80 81 |
# File 'app/models/user.rb', line 77 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
71 72 73 74 75 |
# File 'app/models/user.rb', line 71 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
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/models/user.rb', line 30 def role?(role) case role when :admin admin? when :designer designer? when :content_editor content_editor? else false end end |
#scoped_site? ⇒ Boolean
59 60 61 |
# File 'app/models/user.rb', line 59 def scoped_site? sites.present? end |