Retrospring/app/models/totp_recovery_code.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

12 lines
300 B
Ruby
Raw Normal View History

2020-11-01 08:55:31 -08:00
class TotpRecoveryCode < ApplicationRecord
2020-11-15 01:21:06 -08:00
NUMBER_OF_CODES_TO_GENERATE = 16
2020-11-01 08:55:31 -08:00
belongs_to :user
2020-11-15 01:21:06 -08:00
# @param user [User]
# @return [Array<TotpRecoveryCode>]
def self.generate_for(user)
TotpRecoveryCode.create!(Array.new(16) { {user: user, code: SecureRandom.base58(8).downcase} })
end
2020-11-01 08:55:31 -08:00
end