Skip to content

Commit

Permalink
Make rodauth.*_email_recently_sent? methods public
Browse files Browse the repository at this point in the history
This affects the following methods:

* email_auth_email_recently_sent?
* unlock_account_email_recently_sent?
* reset_password_email_recently_sent?
* verify_account_email_recently_sent?

This provides a supported method for the user to check whether
the related emails have been recently sent.
  • Loading branch information
jeremyevans committed Dec 17, 2024
1 parent 589aac5 commit 5bd816a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
=== master

* Make rodauth.*_email_recently_sent? methods public (jeremyevans)

* Add Rodauth::ConfigurationError, and use it for configuration errors (janko) (#458)

=== 2.37.0 (2024-11-19)
Expand Down
8 changes: 4 additions & 4 deletions lib/rodauth/features/email_auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ def possible_authentication_methods
methods
end

def email_auth_email_recently_sent?
(email_last_sent = get_email_auth_email_last_sent) && (Time.now - email_last_sent < email_auth_skip_resend_email_within)
end

private

def _multi_phase_login_forms
Expand All @@ -171,10 +175,6 @@ def _multi_phase_login_forms
forms
end

def email_auth_email_recently_sent?
(email_last_sent = get_email_auth_email_last_sent) && (Time.now - email_last_sent < email_auth_skip_resend_email_within)
end

def _email_auth_request
if email_auth_email_recently_sent?
set_redirect_error_flash email_auth_email_recently_sent_error_flash
Expand Down
8 changes: 4 additions & 4 deletions lib/rodauth/features/lockout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ def set_unlock_account_email_last_sent
account_lockouts_ds.update(account_lockouts_email_last_sent_column=>Sequel::CURRENT_TIMESTAMP) if account_lockouts_email_last_sent_column
end

def unlock_account_email_recently_sent?
(email_last_sent = get_unlock_account_email_last_sent) && (Time.now - email_last_sent < unlock_account_skip_resend_email_within)
end

private

attr_reader :unlock_account_key_value
Expand Down Expand Up @@ -278,10 +282,6 @@ def show_lockout_page
return_response unlock_account_request_view
end

def unlock_account_email_recently_sent?
(email_last_sent = get_unlock_account_email_last_sent) && (Time.now - email_last_sent < unlock_account_skip_resend_email_within)
end

def use_date_arithmetic?
super || db.database_type == :mysql
end
Expand Down
8 changes: 4 additions & 4 deletions lib/rodauth/features/reset_password.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,16 @@ def get_reset_password_email_last_sent
end
end

def reset_password_email_recently_sent?
(email_last_sent = get_reset_password_email_last_sent) && (Time.now - email_last_sent < reset_password_skip_resend_email_within)
end

private

def _login_form_footer_links
super << [20, reset_password_request_path, reset_password_request_link_text]
end

def reset_password_email_recently_sent?
(email_last_sent = get_reset_password_email_last_sent) && (Time.now - email_last_sent < reset_password_skip_resend_email_within)
end

attr_reader :reset_password_key_value

def after_login_failure
Expand Down
8 changes: 4 additions & 4 deletions lib/rodauth/features/verify_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ def setup_account_verification
send_verify_account_email
end

def verify_account_email_recently_sent?
(email_last_sent = get_verify_account_email_last_sent) && (Time.now - email_last_sent < verify_account_skip_resend_email_within)
end

private

def _login_form_footer_links
Expand All @@ -250,10 +254,6 @@ def _login_form_footer_links
links
end

def verify_account_email_recently_sent?
(email_last_sent = get_verify_account_email_last_sent) && (Time.now - email_last_sent < verify_account_skip_resend_email_within)
end

attr_reader :verify_account_key_value

def before_login_attempt
Expand Down

0 comments on commit 5bd816a

Please sign in to comment.