Class: Workarea::User

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Methods included from Avatar

#avatar_image_url, #gravatar_url

Methods included from Commentable

#add_subscription, #remove_subscription

Methods included from SystemUsers

#system?

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

included

Methods included from ApplicationDocument

#releasable?

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

#embedded_children

Class Method Details

.find_admin(id) ⇒ User?

Find an admin user by id. This searches across sites, but limited to only admin users.

Parameters:

Returns:



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

Parameters:

Returns:



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

#initialsString

Returns initials from name fields, falling back to email initial.

Returns:



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_infoString

Returns public display name. Always includes initials, optionally includes city if present.

Returns:



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