File: otp_lockout_email.rb

package info (click to toggle)
ruby-rodauth 2.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 812 kB
  • sloc: ruby: 7,524; javascript: 100; makefile: 4
file content (42 lines) | stat: -rw-r--r-- 1,136 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 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