Class: Rodauth::Rails::Generators::ViewsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Rodauth::Rails::Generators::ViewsGenerator
- Defined in:
- lib/generators/rodauth/views_generator.rb
Constant Summary collapse
- VIEWS =
{ login: %w[_login_form _login_form_footer _login_form_header 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], }
- DEPENDENCIES =
{ otp: :two_factor_base, sms_codes: :two_factor_base, recovery_codes: :two_factor_base, webauthn: :two_factor_base, }
Instance Method Summary collapse
Instance Method Details
#create_views ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/generators/rodauth/views_generator.rb', line 48 def create_views views = features.inject([]) do |list, feature| list |= VIEWS[feature] || [] list |= VIEWS[DEPENDENCIES[feature]] || [] end views.each do |view| copy_file "app/views/rodauth/#{view}.html.erb", "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 |