Class: Workarea::User
- Inherits:
-
Object
- Object
- Workarea::User
- Includes:
- Mongoid::Document::Taggable, ApplicationDocument, Commentable, NormalizeEmail, Addresses, Authorization, Avatar, Login, Passwords, SystemUsers
- Defined in:
- app/models/workarea/user.rb,
app/models/workarea/user/login.rb,
app/models/workarea/user/avatar.rb,
app/models/workarea/user/addresses.rb,
app/models/workarea/user/passwords.rb,
app/models/workarea/user/admin_visit.rb,
app/models/workarea/user/system_users.rb,
app/models/workarea/user/authorization.rb,
app/models/workarea/user/saved_address.rb,
app/models/workarea/user/admin_bookmark.rb,
app/models/workarea/user/password_reset.rb,
app/models/workarea/user/recent_password.rb
Defined Under Namespace
Modules: Addresses, Authorization, Avatar, Login, Passwords, SystemUsers Classes: AdminBookmark, AdminVisit, PasswordReset, RecentPassword, SavedAddress
Class Method Summary collapse
-
.find_admin(id) ⇒ User?
Find an admin user by id.
-
.find_by_email(email) ⇒ User
Find a user by email, case-insensitive.
Instance Method Summary collapse
-
#initials ⇒ String
Returns initials from name fields, falling back to email initial.
-
#public_info ⇒ String
Returns public display name.
Methods included from Avatar
#avatar_image_url, #gravatar_url
Methods included from Commentable
#add_subscription, #remove_subscription
Methods included from SystemUsers
Methods included from Addresses
#auto_save_billing_address, #auto_save_shipping_address, #default_billing_address, #default_shipping_address
Methods included from Login
#login_failure!, #login_locked?, #login_success!, #unlock_login!, #update_login!, #valid_logged_in_request?
Methods included from Passwords
#force_password_change?, #required_password_strength
Methods included from Authorization
#mark_impersonated_by!, #no_longer_admin?, #super_admin=
Methods included from Mongoid::Document::Taggable
Methods included from ApplicationDocument
Methods included from Sidekiq::Callbacks
add_worker, assert_valid_config!, async, caching_classes?, disable, enable, inline, #run_callbacks, workers, workers_list
Methods included from Mongoid::Document
Class Method Details
.find_admin(id) ⇒ User?
Find an admin user by id. This searches across sites, but limited to only admin users.
48 49 50 |
# File 'app/models/workarea/user.rb', line 48 def self.find_admin(id) admins.find(id) rescue nil end |
.find_by_email(email) ⇒ User
Find a user by email, case-insensitive
36 37 38 39 |
# File 'app/models/workarea/user.rb', line 36 def self.find_by_email(email) return nil if email.blank? find_by(email: email.to_s.downcase.strip) rescue nil end |
Instance Method Details
#initials ⇒ String
Returns initials from name fields, falling back to email initial.
72 73 74 75 76 77 78 |
# File 'app/models/workarea/user.rb', line 72 def initials if first_name.present? && last_name.present? [first_name[0], last_name[0]].join else email[0] end end |
#public_info ⇒ String
Returns public display name. Always includes initials, optionally includes city if present.
57 58 59 60 61 62 63 64 65 66 |
# File 'app/models/workarea/user.rb', line 57 def public_info return nil unless first_name.present? && last_name.present? city = default_billing_address.try(:city) if city.present? "#{initials} from #{city}" else initials end end |