Class: Rodauth::Rails::Generators::MailerGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/rodauth/mailer_generator.rb

Constant Summary collapse

EMAILS =
{
  verify_account:         %w[verify_account],
  reset_password:         %w[reset_password],
  verify_login_change:    %w[verify_login_change],
  email_auth:             %w[email_auth],
  lockout:                %w[unlock_account],
  reset_password_notify:  %w[reset_password_notify],
  change_password_notify: %w[password_changed],
  otp_modify_email:       %w[otp_setup otp_disabled],
  otp_lockout_email:      %w[otp_locked_out otp_unlocked otp_unlock_failed],
  webauthn_modify_email:  %w[webauthn_authenticator_added webauthn_authenticator_removed],
}
TOKENS =
%w[reset_password verify_account verify_login_change email_auth unlock_account]

Instance Method Summary collapse

Instance Method Details

#copy_mailerObject



44
45
46
47
48
49
50
51
52
# File 'lib/generators/rodauth/mailer_generator.rb', line 44

def copy_mailer
  return unless validate_features

  if File.exist?("#{destination_root}/app/mailers/rodauth_mailer.rb") && options.fetch(:skip, true) && !options[:force] && behavior == :invoke
    say "\nCopy the following lines into your Rodauth mailer:\n\n#{mailer_content}"
  else
    template "app/mailers/rodauth_mailer.rb"
  end
end

#copy_mailer_viewsObject



36
37
38
39
40
41
42
# File 'lib/generators/rodauth/mailer_generator.rb', line 36

def copy_mailer_views
  return unless validate_features

  emails.each do |email|
    copy_file "app/views/rodauth_mailer/#{email}.text.erb"
  end
end

#show_configurationObject



54
55
56
57
58
# File 'lib/generators/rodauth/mailer_generator.rb', line 54

def show_configuration
  return unless behavior == :invoke && validate_features

  say "\nCopy the following lines into your Rodauth configuration:\n\n#{configuration_content}"
end