Class: Lesli::User

Inherits:
ApplicationLesliRecord show all
Includes:
UserExtensions, UserSecurity
Defined in:
app/models/lesli/user.rb

Defined Under Namespace

Classes: Agent, Detail, Log, Power, Request, Session, Setting

Instance Method Summary collapse

Methods included from UserExtensions

#calendar, #full_name, #full_name_initials, #locale, #mfa_settings, #name2, #notification, #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?, #max_object_level_permission, #password_reset, #revoke_access, #set_password_as_expired, #telephone_confirmed?

Instance Method Details

#after_account_assignationObject



125
126
127
128
129
130
# File 'app/models/lesli/user.rb', line 125

def 
    return unless self.

    #Courier::One::Firebase::User.sync_user(self)
    #Courier::Driver::Calendar.create_user_calendar(self, name: "Personal Calendar", default: true)
end

#after_confirmation_userObject

Initialize user settings and dependencies needed



110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'app/models/lesli/user.rb', line 110

def after_confirmation_user
    return unless self.confirmed?

    # create an alias based on user name
    # defined in user extensions
    self.set_alias

    # create user details
    User::Detail.find_or_create_by({ user: self })

    # 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

#before_create_uservoid

This method returns an undefined value.



104
105
106
# File 'app/models/lesli/user.rb', line 104

def before_create_user
    self.email = (self.email||"").downcase
end

#save(*args) ⇒ Object

allow save duplicated users to execute callbacks



96
97
98
99
# File 'app/models/lesli/user.rb', line 96

def save(*args)
    super()
    rescue ActiveRecord::RecordNotUnique => error
end

#update_associated_servicesObject



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'app/models/lesli/user.rb', line 133

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