Class: Rodauth::Rails::Generators::ViewsGenerator

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

Constant Summary collapse

VIEWS =
{
  login:               %w[_login_form _login_form_footer login multi_phase_login],
  create_account:      %w[create_account],
  logout:              %w[logout],
  reset_password:      %w[reset_password_request reset_password],
  remember:            %w[remember],
  change_login:        %w[change_login],
  change_password:     %w[change_password],
  close_account:       %w[close_account],
  email_auth:          %w[_email_auth_request_form email_auth],
  verify_account:      %w[verify_account_resend verify_account],
  verify_login_change: %w[verify_login_change],
  lockout:             %w[unlock_account_request unlock_account],
  two_factor_base:     %w[two_factor_manage two_factor_auth two_factor_disable],
  otp:                 %w[otp_setup otp_auth otp_disable],
  sms_codes:           %w[sms_setup sms_confirm sms_auth sms_request sms_disable],
  recovery_codes:      %w[recovery_codes add_recovery_codes recovery_auth],
  webauthn:            %w[webauthn_setup webauthn_auth webauthn_remove],
  webauthn_autofill:   %w[webauthn_autofill],
  confirm_password:    %w[confirm_password],
}

Instance Method Summary collapse

Instance Method Details

#create_viewsObject



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/generators/rodauth/views_generator.rb', line 47

def create_views
  validate_features or return

  views.each do |view|
    copy_file view_location(view), "app/views/#{directory}/#{view}.html.erb" do |content|
      content = content.gsub("rodauth.", "rodauth(:#{configuration_name}).") if configuration_name
      content = content.gsub("rodauth/", "#{directory}/")
      content = form_helpers_compatibility(content) if ActionView.version < Gem::Version.new("5.1")
      content
    end
  end
end