Skip to content

Commit

Permalink
Add mailer templates for webauthn_modify_email feature
Browse files Browse the repository at this point in the history
  • Loading branch information
janko committed Jul 23, 2024
1 parent 25e9ab3 commit 36191e0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/generators/rodauth/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class InstallGenerator < ::Rails::Generators::Base
otp_unlock_failed
otp_setup
otp_disabled
webauthn_authenticator_added
webauthn_authenticator_removed
]

source_root "#{__dir__}/templates"
Expand Down
14 changes: 14 additions & 0 deletions lib/generators/rodauth/templates/app/mailers/rodauth_mailer.rb.tt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ class RodauthMailer < ApplicationMailer
# mail subject: @rodauth.email_subject_prefix + @rodauth.otp_disabled_email_subject
# end

# def webauthn_authenticator_added(name, account_id)
# @rodauth = rodauth(name, account_id)
# @account = @rodauth.rails_account

# mail subject: @rodauth.email_subject_prefix + @rodauth.webauthn_authenticator_added_email_subject
# end

# def webauthn_authenticator_removed(name, account_id)
# @rodauth = rodauth(name, account_id)
# @account = @rodauth.rails_account

# mail subject: @rodauth.email_subject_prefix + @rodauth.webauthn_authenticator_removed_email_subject
# end

private

# Default URL options are inherited from Action Mailer, but you can override them
Expand Down
6 changes: 6 additions & 0 deletions lib/generators/rodauth/templates/app/misc/rodauth_main.rb.tt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ class RodauthMain < Rodauth::Rails::Auth
# create_otp_disabled_email do
# RodauthMailer.otp_disabled(self.class.configuration_name, account_id)
# end
# create_webauthn_authenticator_added_email do
# RodauthMailer.webauthn_authenticator_added(self.class.configuration_name, account_id)
# end
# create_webauthn_authenticator_removed_email do
# RodauthMailer.webauthn_authenticator_removed(self.class.configuration_name, account_id)
# end
send_email do |email|
# queue email delivery on the mailer after the transaction commits
db.after_commit { email.deliver_later }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Someone (hopefully you) has added a WebAuthn authenticator to the
account associated to this email address. There are now <%= @account.webauthn_keys.count %> WebAuthn
authenticator(s) with access to the account.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Someone (hopefully you) has removed a WebAuthn authenticator from the
account associated to this email address. There are now <%= @account.webauthn_keys.count %> WebAuthn
authenticator(s) with access to the account.

0 comments on commit 36191e0

Please sign in to comment.