Class: Lesli::User
- Inherits:
-
ApplicationLesliRecord
- Object
- ActiveRecord::Base
- ApplicationLesliRecord
- Lesli::User
- Includes:
- UserExtensions, UserSecurity
- Defined in:
- app/models/lesli/user.rb
Defined Under Namespace
Classes: Activity, Detail, Journal, Request, Role, Session, SessionService, Setting
Instance Method Summary collapse
- #after_account_assignation ⇒ Object
-
#after_confirmation ⇒ Object
Initialize user settings and dependencies needed.
- #after_create_user ⇒ Object
- #before_create_user ⇒ void
-
#save(*args) ⇒ Object
allow save duplicated users to execute callbacks.
- #update_associated_services ⇒ Object
Methods included from UserExtensions
#calendar, #full_name, #full_name_initials, #locale, #mfa_settings, #notification, #notifications, #role_names, #set_alias
Methods included from UserSecurity
#abilities_by_controller, #can_work_with_role?, #confirm_telephone_number, #generate_password_reset_token, #generate_telephone_token, #has_expired_password?, #has_privileges_for?, #has_role_limited_to_path?, #has_role_with_default_path?, #has_roles?, #has_telephone_confirmed?, #max_level_permission, #revoke_access, #set_password_as_expired, #set_password_for_reset
Instance Method Details
#after_account_assignation ⇒ Object
111 112 113 114 115 116 117 118 119 |
# File 'app/models/lesli/user.rb', line 111 def after_account_assignation return unless self.account #Courier::One::Firebase::User.sync_user(self) # Lesli::Courier.new(:lesli_calendar).from(:calendar_service, self).create({ # name: "Personal Calendar", # default: true # }) end |
#after_confirmation ⇒ Object
Initialize user settings and dependencies needed
123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'app/models/lesli/user.rb', line 123 def after_confirmation return unless self.confirmed? self.activities.create(title: "create_user", description:"User confirmed") # create an alias based on user name defined in user extensions self.set_alias # Minimum security settings required #self.settings.create_with(:value => false).find_or_create_by(:name => "mfa_enabled") #self.settings.create_with(:value => :email).find_or_create_by(:name => "mfa_method") end |
#after_create_user ⇒ Object
104 105 106 107 108 |
# File 'app/models/lesli/user.rb', line 104 def after_create_user self.activities.create(title: "create_user", description:"User created") after_confirmation after_account_assignation end |
#before_create_user ⇒ void
This method returns an undefined value.
99 100 101 |
# File 'app/models/lesli/user.rb', line 99 def before_create_user self.email = self.email.downcase end |
#save(*args) ⇒ Object
allow save duplicated users to execute callbacks
91 92 93 94 |
# File 'app/models/lesli/user.rb', line 91 def save(*args) super() rescue ActiveRecord::RecordNotUnique => error end |
#update_associated_services ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'app/models/lesli/user.rb', line 137 def update_associated_services if saved_change_to_first_name? || saved_change_to_last_name? || saved_change_to_telephone? # defined in user extensions self.set_alias return if defined? CloudOne data = { full_name: self.user.full_name, telephone: self.telephone, } CloudOne::Firebase::User.update_data(self.user, data) end end end |