From 332ec93366315fa1ed7b4acd7a3407c96e8ddfa7 Mon Sep 17 00:00:00 2001 From: sadbeast Date: Wed, 31 Jan 2024 17:47:56 -0800 Subject: initial mistake --- app/mailers/application_mailer.rb | 4 +++ app/mailers/rodauth_mailer.rb | 62 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 app/mailers/application_mailer.rb create mode 100644 app/mailers/rodauth_mailer.rb (limited to 'app/mailers') diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb new file mode 100644 index 0000000..3c34c81 --- /dev/null +++ b/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: "from@example.com" + layout "mailer" +end diff --git a/app/mailers/rodauth_mailer.rb b/app/mailers/rodauth_mailer.rb new file mode 100644 index 0000000..6782c87 --- /dev/null +++ b/app/mailers/rodauth_mailer.rb @@ -0,0 +1,62 @@ +class RodauthMailer < ApplicationMailer + default to: -> { @rodauth.email_to }, from: -> { @rodauth.email_from } + + def verify_account(name, account_id, key) + @rodauth = rodauth(name, account_id) { @verify_account_key_value = key } + @account = @rodauth.rails_account + + mail subject: @rodauth.email_subject_prefix + @rodauth.verify_account_email_subject + end + + def reset_password(name, account_id, key) + @rodauth = rodauth(name, account_id) { @reset_password_key_value = key } + @account = @rodauth.rails_account + + mail subject: @rodauth.email_subject_prefix + @rodauth.reset_password_email_subject + end + + def verify_login_change(name, account_id, key) + @rodauth = rodauth(name, account_id) { @verify_login_change_key_value = key } + @account = @rodauth.rails_account + @new_email = @account.login_change_key.login + + mail to: @new_email, subject: @rodauth.email_subject_prefix + @rodauth.verify_login_change_email_subject + end + + def password_changed(name, account_id) + @rodauth = rodauth(name, account_id) + @account = @rodauth.rails_account + + mail subject: @rodauth.email_subject_prefix + @rodauth.password_changed_email_subject + end + + # def reset_password_notify(name, account_id) + # @rodauth = rodauth(name, account_id) + # @account = @rodauth.rails_account + + # mail subject: @rodauth.email_subject_prefix + @rodauth.reset_password_notify_email_subject + # end + + # def email_auth(name, account_id, key) + # @rodauth = rodauth(name, account_id) { @email_auth_key_value = key } + # @account = @rodauth.rails_account + + # mail subject: @rodauth.email_subject_prefix + @rodauth.email_auth_email_subject + # end + + # def unlock_account(name, account_id, key) + # @rodauth = rodauth(name, account_id) { @unlock_account_key_value = key } + # @account = @rodauth.rails_account + + # mail subject: @rodauth.email_subject_prefix + @rodauth.unlock_account_email_subject + # end + + private + + def rodauth(name, account_id, &block) + instance = RodauthApp.rodauth(name).allocate + instance.instance_eval { @account = account_ds(account_id).first! } + instance.instance_eval(&block) if block + instance + end +end -- cgit v1.2.3