Sha256: acab1ec5392887fdbee1abf31eb20cb53354773fecd2e59c54c2dca641b8c75e
Contents?: true
Size: 1.24 KB
Versions: 9
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true require 'devise-security/hooks/paranoid_verification' module Devise module Models # PasswordExpirable takes care of change password after module ParanoidVerification extend ActiveSupport::Concern def need_paranoid_verification? !!paranoid_verification_code end def verify_code(code) attempt = paranoid_verification_attempt if (attempt += 1) >= Devise.paranoid_code_regenerate_after_attempt generate_paranoid_code elsif code == paranoid_verification_code attempt = 0 update_without_password paranoid_verification_code: nil, paranoid_verified_at: Time.now, paranoid_verification_attempt: attempt else update_without_password paranoid_verification_attempt: attempt end end def paranoid_attempts_remaining Devise.paranoid_code_regenerate_after_attempt - paranoid_verification_attempt end def generate_paranoid_code update_without_password paranoid_verification_code: Devise.verification_code_generator.call(), paranoid_verification_attempt: 0 end end end end
Version data entries
9 entries across 9 versions & 1 rubygems