Class: Users::RestorePasswordWorker

Inherits:
ApplicationWorker show all
Defined in:
app/workers/users/restore_password_worker.rb

Instance Method Summary collapse

Methods inherited from ApplicationWorker

unlimited_retry

Instance Method Details

#perform(user_id) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/workers/users/restore_password_worker.rb', line 3

def perform(user_id)
  user = User.find_by(id: user_id)

  return if user.blank?

  if user.encrypted_password_backup.nil?
    APMErrorHandler.report("User #{user_id} does not have a password backup")
    return
  end

  user.update!(encrypted_password: user.encrypted_password_backup, encrypted_password_backup: nil)
rescue StandardError => e
  Rails.logger.error "RestorePasswordWorker failed for User #{user_id}: #{e.message}"
end