Sha256: 4dfa3c286c8ca2cc63898646b9b0259bf65b0f8f08734905e2384b604c9d3097
Contents?: true
Size: 778 Bytes
Versions: 3
Compression:
Stored size: 778 Bytes
Contents
class TwoFactorAuthentication::RecoveryCodesController < ApplicationController before_action :set_user def index if Current.user.recovery_codes.exists? @recovery_codes = @user.recovery_codes else @recovery_codes = @user.recovery_codes.create!(new_recovery_codes) end end def create @user.recovery_codes.delete_all @user.recovery_codes.create!(new_recovery_codes) redirect_to two_factor_authentication_recovery_codes_path, notice: "Your new recovery codes have been generated" end private def set_user @user = Current.user end def new_recovery_codes 10.times.map { { code: new_recovery_code } } end def new_recovery_code SecureRandom.alphanumeric(10).insert(5, "-").downcase end end
Version data entries
3 entries across 3 versions & 1 rubygems