Sha256: 0bfa490b96db22e95c5ee90fd51fcd2e319b3e2c839096c0b7fc2af68d614704
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
devise-security-0.11.1 | lib/devise-security/models/paranoid_verification.rb |
devise-security-0.11.0 | lib/devise-security/models/paranoid_verification.rb |