Sha256: 348851f1385010223be7023ed4595c9810904aa5bb4226064360fbf5d3528d9f

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

# frozen-string-literal: true

module Rodauth
  Feature.define(:otp_lockout_email, :OtpLockoutEmail) do
    depends :otp_unlock, :email_base

    loaded_templates %w'otp-locked-out-email otp-unlocked-email otp-unlock-failed-email'
    email :otp_locked_out, 'TOTP Authentication Locked Out', :translatable=>true
    email :otp_unlocked, 'TOTP Authentication Unlocked', :translatable=>true
    email :otp_unlock_failed, 'TOTP Authentication Unlocking Failed', :translatable=>true

    auth_value_method :send_otp_locked_out_email?, true
    auth_value_method :send_otp_unlocked_email?, true
    auth_value_method :send_otp_unlock_failed_email?, true

    private

    def after_otp_authentication_failure
      super

      if otp_locked_out? && send_otp_locked_out_email?
        send_otp_locked_out_email
      end
    end

    def after_otp_unlock_auth_success
      super

      if !otp_locked_out? && send_otp_unlocked_email?
        send_otp_unlocked_email
      end
    end

    def after_otp_unlock_auth_failure
      super

      if send_otp_unlock_failed_email?
        send_otp_unlock_failed_email
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rodauth-2.38.0 lib/rodauth/features/otp_lockout_email.rb
rodauth-2.37.0 lib/rodauth/features/otp_lockout_email.rb
rodauth-2.36.0 lib/rodauth/features/otp_lockout_email.rb