plutonium 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/.standard.yml +4 -0
- data/.vscode/extensions.json +15 -0
- data/.vscode/launch.json +7 -0
- data/.vscode/settings.json +35 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README copy.md +84 -0
- data/README.md +67 -0
- data/Rakefile +8 -0
- data/app/views/layouts/resource.html.erb +43 -0
- data/app/views/resource/_color_modes.html.erb +55 -0
- data/app/views/resource/_details.html.erb +6 -0
- data/app/views/resource/_empty_card.html.erb +12 -0
- data/app/views/resource/_flash.html.erb +9 -0
- data/app/views/resource/_form.html.erb +32 -0
- data/app/views/resource/_header.html.erb +8 -0
- data/app/views/resource/_interactive_resource_action_form.html.erb +67 -0
- data/app/views/resource/_messages.html.erb +1 -0
- data/app/views/resource/_metric_card.html.erb +16 -0
- data/app/views/resource/_nav_user.html.erb +4 -0
- data/app/views/resource/_pagination.html.erb +6 -0
- data/app/views/resource/_pagy_pagination.html.erb +15 -0
- data/app/views/resource/_resource.html.erb +1 -0
- data/app/views/resource/_resource.rabl +5 -0
- data/app/views/resource/_sidebar.html.erb +11 -0
- data/app/views/resource/_sidebar_menu.html.erb +1 -0
- data/app/views/resource/_tab_menu.html.erb +13 -0
- data/app/views/resource/_table.html.erb +78 -0
- data/app/views/resource/_table_actions.html.erb +15 -0
- data/app/views/resource/_toast.html.erb +26 -0
- data/app/views/resource/_toolbar.html.erb +22 -0
- data/app/views/resource/_toolbar_actions.html.erb +16 -0
- data/app/views/resource/_toolbar_breadcrumbs.html.erb +32 -0
- data/app/views/resource/_toolbar_search_input.erb +27 -0
- data/app/views/resource/edit.html.erb +10 -0
- data/app/views/resource/errors.rabl +3 -0
- data/app/views/resource/index.html.erb +19 -0
- data/app/views/resource/index.rabl +3 -0
- data/app/views/resource/interactive_resource_collection_action.html.erb +11 -0
- data/app/views/resource/interactive_resource_record_action.html.erb +11 -0
- data/app/views/resource/interactive_resource_recordless_action.html.erb +11 -0
- data/app/views/resource/new.html.erb +11 -0
- data/app/views/resource/readme.md +16 -0
- data/app/views/resource/show.html.erb +14 -0
- data/app/views/resource/show.rabl +3 -0
- data/brakeman.ignore +51 -0
- data/lib/active_model/validations/array_validator.rb +74 -0
- data/lib/active_model/validations/attached_validator.rb +17 -0
- data/lib/active_model/validations/url_validator.rb +51 -0
- data/lib/generators/pu/core/install/install_generator.rb +43 -0
- data/lib/generators/pu/core/install/templates/.keep +0 -0
- data/lib/generators/pu/core/install/templates/app/controllers/resource_controller.rb.tt +2 -0
- data/lib/generators/pu/core/install/templates/app/interactions/resource_interaction.rb.tt +2 -0
- data/lib/generators/pu/core/install/templates/app/models/resource_record.rb.tt +5 -0
- data/lib/generators/pu/core/install/templates/app/policies/resource_policy.rb.tt +2 -0
- data/lib/generators/pu/core/install/templates/app/presenters/resource_presenter.rb.tt +2 -0
- data/lib/generators/pu/core/install/templates/config/initializers/plutonium.rb +2 -0
- data/lib/generators/pu/core/install/templates/config/packages.rb +3 -0
- data/lib/generators/pu/gem/pagy/pagy_generator.rb +25 -0
- data/lib/generators/pu/gem/pagy/templates/.keep +0 -0
- data/lib/generators/pu/gem/pagy/templates/config/initializers/pagy.rb +4 -0
- data/lib/generators/pu/gem/rabl/rabl_generator.rb +25 -0
- data/lib/generators/pu/gem/rabl/templates/.keep +0 -0
- data/lib/generators/pu/gem/rabl/templates/config/initializers/rabl.rb +60 -0
- data/lib/generators/pu/gem/simple_form/simple_form_generator.rb +25 -0
- data/lib/generators/pu/gem/simple_form/templates/.keep +0 -0
- data/lib/generators/pu/gen/pug/pug_generator.rb +43 -0
- data/lib/generators/pu/gen/pug/templates/pug.rb.tt +23 -0
- data/lib/generators/pu/pkg/app/app_generator.rb +60 -0
- data/lib/generators/pu/pkg/app/templates/app/controllers/resource_controller.rb.tt +26 -0
- data/lib/generators/pu/pkg/app/templates/app/interactions/resource_interaction.rb.tt +4 -0
- data/lib/generators/pu/pkg/app/templates/app/policies/resource_policy.rb.tt +4 -0
- data/lib/generators/pu/pkg/app/templates/app/presenters/resource_presenter.rb.tt +4 -0
- data/lib/generators/pu/pkg/app/templates/config/routes.rb.tt +17 -0
- data/lib/generators/pu/pkg/app/templates/lib/engine.rb.tt +14 -0
- data/lib/generators/pu/pkg/feature/feature_generator.rb +44 -0
- data/lib/generators/pu/pkg/feature/templates/.keep +0 -0
- data/lib/generators/pu/pkg/feature/templates/app/controllers/resource_controller.rb.tt +7 -0
- data/lib/generators/pu/pkg/feature/templates/app/interactions/resource_interaction.rb.tt +4 -0
- data/lib/generators/pu/pkg/feature/templates/app/models/resource_record.rb.tt +5 -0
- data/lib/generators/pu/pkg/feature/templates/app/policies/resource_policy.rb.tt +4 -0
- data/lib/generators/pu/pkg/feature/templates/app/presenters/resource_presenter.rb.tt +4 -0
- data/lib/generators/pu/pkg/feature/templates/lib/engine.rb.tt +8 -0
- data/lib/generators/pu/resource/conn/conn_generator.rb +54 -0
- data/lib/generators/pu/resource/conn/templates/.keep +0 -0
- data/lib/generators/pu/resource/conn/templates/app/controllers/resource_controller.rb.tt +3 -0
- data/lib/generators/pu/resource/conn/templates/app/policies/resource_policy.rb.tt +3 -0
- data/lib/generators/pu/resource/conn/templates/app/presenters/resource_presenter.rb.tt +3 -0
- data/lib/generators/pu/resource/model/USAGE +113 -0
- data/lib/generators/pu/resource/model/model_generator.rb +163 -0
- data/lib/generators/pu/resource/model/templates/controller.rb.tt +5 -0
- data/lib/generators/pu/resource/model/templates/create_table_migration.rb.tt +26 -0
- data/lib/generators/pu/resource/model/templates/model.rb.tt +53 -0
- data/lib/generators/pu/resource/model/templates/module.rb.tt +7 -0
- data/lib/generators/pu/resource/model/templates/policy.rb.tt +4 -0
- data/lib/generators/pu/resource/model/templates/presenter.rb.tt +4 -0
- data/lib/generators/pu/resource/scaffold/scaffold_generator.rb +219 -0
- data/lib/generators/pu/resource/scaffold/templates/app/controllers/admin_resources/resource_controller.rb.tt +7 -0
- data/lib/generators/pu/resource/scaffold/templates/app/controllers/entity_resources/resource_controller.rb.tt +7 -0
- data/lib/generators/pu/resource/scaffold/templates/app/policies/resources/admin/resource_policy.rb.tt +22 -0
- data/lib/generators/pu/resource/scaffold/templates/app/policies/resources/entity/resource_policy.rb.tt +22 -0
- data/lib/generators/pu/resource/scaffold/templates/app/policies/resources/resource_policy.rb.tt +13 -0
- data/lib/generators/pu/resource/scaffold/templates/app/resources/resource/admin_presenter.rb.tt +7 -0
- data/lib/generators/pu/resource/scaffold/templates/app/resources/resource/entity_presenter.rb.tt +7 -0
- data/lib/generators/pu/resource/scaffold/templates/app/resources/resource/presenter.rb.tt +23 -0
- data/lib/generators/pu/resource/scaffold/templates/app/views/resources/resource/_resource.html.erb.tt +3 -0
- data/lib/generators/pu/resource/scaffold/templates/app/views/resources/resource/_resource.rabl +7 -0
- data/lib/generators/pu/rodauth/account_generator.rb +120 -0
- data/lib/generators/pu/rodauth/concerns/account_selector.rb +22 -0
- data/lib/generators/pu/rodauth/concerns/configuration.rb +211 -0
- data/lib/generators/pu/rodauth/concerns/feature_selector.rb +125 -0
- data/lib/generators/pu/rodauth/install_generator.rb +69 -0
- data/lib/generators/pu/rodauth/migration/active_record/account_expiration.erb +8 -0
- data/lib/generators/pu/rodauth/migration/active_record/active_sessions.erb +7 -0
- data/lib/generators/pu/rodauth/migration/active_record/audit_logging.erb +16 -0
- data/lib/generators/pu/rodauth/migration/active_record/base.erb +22 -0
- data/lib/generators/pu/rodauth/migration/active_record/disallow_password_reuse.erb +5 -0
- data/lib/generators/pu/rodauth/migration/active_record/email_auth.erb +8 -0
- data/lib/generators/pu/rodauth/migration/active_record/jwt_refresh.erb +7 -0
- data/lib/generators/pu/rodauth/migration/active_record/lockout.erb +13 -0
- data/lib/generators/pu/rodauth/migration/active_record/otp.erb +8 -0
- data/lib/generators/pu/rodauth/migration/active_record/password_expiration.erb +6 -0
- data/lib/generators/pu/rodauth/migration/active_record/recovery_codes.erb +6 -0
- data/lib/generators/pu/rodauth/migration/active_record/remember.erb +7 -0
- data/lib/generators/pu/rodauth/migration/active_record/reset_password.erb +8 -0
- data/lib/generators/pu/rodauth/migration/active_record/separate_passwords.erb +5 -0
- data/lib/generators/pu/rodauth/migration/active_record/single_session.erb +6 -0
- data/lib/generators/pu/rodauth/migration/active_record/sms_codes.erb +9 -0
- data/lib/generators/pu/rodauth/migration/active_record/verify_account.erb +8 -0
- data/lib/generators/pu/rodauth/migration/active_record/verify_login_change.erb +8 -0
- data/lib/generators/pu/rodauth/migration/active_record/webauthn.erb +13 -0
- data/lib/generators/pu/rodauth/migration/sequel/account_expiration.erb +7 -0
- data/lib/generators/pu/rodauth/migration/sequel/active_sessions.erb +8 -0
- data/lib/generators/pu/rodauth/migration/sequel/audit_logging.erb +17 -0
- data/lib/generators/pu/rodauth/migration/sequel/base.erb +25 -0
- data/lib/generators/pu/rodauth/migration/sequel/disallow_password_reuse.erb +6 -0
- data/lib/generators/pu/rodauth/migration/sequel/email_auth.erb +7 -0
- data/lib/generators/pu/rodauth/migration/sequel/jwt_refresh.erb +8 -0
- data/lib/generators/pu/rodauth/migration/sequel/lockout.erb +11 -0
- data/lib/generators/pu/rodauth/migration/sequel/otp.erb +7 -0
- data/lib/generators/pu/rodauth/migration/sequel/password_expiration.erb +5 -0
- data/lib/generators/pu/rodauth/migration/sequel/recovery_codes.erb +6 -0
- data/lib/generators/pu/rodauth/migration/sequel/remember.erb +6 -0
- data/lib/generators/pu/rodauth/migration/sequel/reset_password.erb +7 -0
- data/lib/generators/pu/rodauth/migration/sequel/separate_passwords.erb +6 -0
- data/lib/generators/pu/rodauth/migration/sequel/single_session.erb +5 -0
- data/lib/generators/pu/rodauth/migration/sequel/sms_codes.erb +8 -0
- data/lib/generators/pu/rodauth/migration/sequel/verify_account.erb +7 -0
- data/lib/generators/pu/rodauth/migration/sequel/verify_login_change.erb +7 -0
- data/lib/generators/pu/rodauth/migration/sequel/webauthn.erb +13 -0
- data/lib/generators/pu/rodauth/migration_generator.rb +190 -0
- data/lib/generators/pu/rodauth/templates/INSTRUCTIONS +52 -0
- data/lib/generators/pu/rodauth/templates/app/controllers/plugin_controller.rb.tt +6 -0
- data/lib/generators/pu/rodauth/templates/app/controllers/rodauth_controller.rb.tt +3 -0
- data/lib/generators/pu/rodauth/templates/app/mailers/account_mailer.rb.tt +4 -0
- data/lib/generators/pu/rodauth/templates/app/mailers/rodauth_mailer.rb.tt +62 -0
- data/lib/generators/pu/rodauth/templates/app/misc/account_rodauth_plugin.rb.tt +255 -0
- data/lib/generators/pu/rodauth/templates/app/misc/rodauth_app.rb.tt +24 -0
- data/lib/generators/pu/rodauth/templates/app/misc/rodauth_plugin.rb.tt +234 -0
- data/lib/generators/pu/rodauth/templates/app/models/account.rb.tt +40 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/_email_auth_request_form.html.erb +7 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/_login_form.html.erb +26 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/_login_form_footer.html.erb +9 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/add_recovery_codes.html.erb +6 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/change_login.html.erb +27 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/change_password.html.erb +27 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/close_account.html.erb +13 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/confirm_password.html.erb +11 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/create_account.html.erb +35 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/email_auth.html.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/login.html.erb +4 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/logout.html.erb +14 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/multi_phase_login.html.erb +3 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/otp_auth.html.erb +15 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/otp_disable.html.erb +13 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/otp_setup.html.erb +41 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/recovery_auth.html.erb +11 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/recovery_codes.html.erb +13 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/remember.html.erb +22 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/reset_password.html.erb +19 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/reset_password_request.html.erb +17 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/sms_auth.html.erb +15 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/sms_confirm.html.erb +15 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/sms_disable.html.erb +13 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/sms_request.html.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/sms_setup.html.erb +23 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/_email_auth_request_form.html.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/_login_form.html.erb +24 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/_login_form_footer.html.erb +7 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/add_recovery_codes.html.erb +16 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/change_login.html.erb +25 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/change_password.html.erb +25 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/close_account.html.erb +11 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/confirm_password.html.erb +19 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/create_account.html.erb +33 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/email_auth.html.erb +3 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/login.html.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/logout.html.erb +10 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/multi_phase_login.html.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/otp_auth.html.erb +9 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/otp_disable.html.erb +11 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/otp_setup.html.erb +32 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/recovery_auth.html.erb +9 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/recovery_codes.html.erb +11 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/remember.html.erb +18 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/reset_password.html.erb +17 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/reset_password_request.html.erb +17 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/sms_auth.html.erb +9 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/sms_confirm.html.erb +9 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/sms_disable.html.erb +11 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/sms_request.html.erb +3 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/sms_setup.html.erb +17 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/two_factor_auth.html.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/two_factor_disable.html.erb +11 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/two_factor_manage.html.erb +26 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/unlock_account.html.erb +15 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/unlock_account_request.html.erb +9 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/verify_account.html.erb +19 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/verify_account_resend.html.erb +17 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/verify_login_change.html.erb +3 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/webauthn_auth.html.erb +13 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/webauthn_autofill.html.erb +10 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/webauthn_remove.html.erb +21 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/tailwind/webauthn_setup.html.erb +21 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/two_factor_auth.html.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/two_factor_disable.html.erb +13 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/two_factor_manage.html.erb +22 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/unlock_account.html.erb +15 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/unlock_account_request.html.erb +9 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/verify_account.html.erb +21 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/verify_account_resend.html.erb +17 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/verify_login_change.html.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/webauthn_auth.html.erb +15 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/webauthn_autofill.html.erb +10 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/webauthn_remove.html.erb +23 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth/webauthn_setup.html.erb +23 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth_mailer/email_auth.text.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth_mailer/password_changed.text.erb +2 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth_mailer/reset_password.text.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth_mailer/reset_password_notify.text.erb +2 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth_mailer/unlock_account.text.erb +5 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth_mailer/verify_account.text.erb +4 -0
- data/lib/generators/pu/rodauth/templates/app/views/rodauth_mailer/verify_login_change.text.erb +10 -0
- data/lib/generators/pu/rodauth/templates/config/initializers/rodauth.rb.tt +3 -0
- data/lib/generators/pu/rodauth/templates/db/migrate/create_rodauth.rb.tt +13 -0
- data/lib/generators/pu/rodauth/views_generator.rb +125 -0
- data/lib/plutonium/auth/public_access.rb +17 -0
- data/lib/plutonium/auth/rodauth.rb +35 -0
- data/lib/plutonium/auth.rb +12 -0
- data/lib/plutonium/config.rb +11 -0
- data/lib/plutonium/core/.DS_Store +0 -0
- data/lib/plutonium/core/action.rb +46 -0
- data/lib/plutonium/core/actions/basic_action.rb +16 -0
- data/lib/plutonium/core/actions/collection.rb +33 -0
- data/lib/plutonium/core/actions/destroy_action.rb +21 -0
- data/lib/plutonium/core/actions/edit_action.rb +19 -0
- data/lib/plutonium/core/actions/interactive_action.rb +64 -0
- data/lib/plutonium/core/actions/new_action.rb +18 -0
- data/lib/plutonium/core/actions/show_action.rb +17 -0
- data/lib/plutonium/core/actions.rb +17 -0
- data/lib/plutonium/core/app_controller.rb +121 -0
- data/lib/plutonium/core/autodiscovery/discoverer.rb +15 -0
- data/lib/plutonium/core/autodiscovery/input_discoverer.rb +33 -0
- data/lib/plutonium/core/autodiscovery/renderer_discoverer.rb +33 -0
- data/lib/plutonium/core/autodiscovery.rb +13 -0
- data/lib/plutonium/core/controllers/authorizable.rb +56 -0
- data/lib/plutonium/core/controllers/bootable.rb +44 -0
- data/lib/plutonium/core/controllers/crud_actions.rb +128 -0
- data/lib/plutonium/core/controllers/entity_scoping.rb +69 -0
- data/lib/plutonium/core/controllers/interactive_actions.rb +210 -0
- data/lib/plutonium/core/controllers/presentable.rb +59 -0
- data/lib/plutonium/core/controllers.rb +16 -0
- data/lib/plutonium/core/definers/action_definer.rb +25 -0
- data/lib/plutonium/core/definers/field_definer.rb +19 -0
- data/lib/plutonium/core/definers/input_definer.rb +37 -0
- data/lib/plutonium/core/definers/renderer_definer.rb +35 -0
- data/lib/plutonium/core/definers.rb +14 -0
- data/lib/plutonium/core/fields/inputs/association_input.rb +26 -0
- data/lib/plutonium/core/fields/inputs/basic_input.rb +42 -0
- data/lib/plutonium/core/fields/inputs/belongs_to_input.rb +15 -0
- data/lib/plutonium/core/fields/inputs/factory.rb +58 -0
- data/lib/plutonium/core/fields/inputs/has_many_input.rb +15 -0
- data/lib/plutonium/core/fields/inputs/noop_input.rb +19 -0
- data/lib/plutonium/core/fields/inputs.rb +18 -0
- data/lib/plutonium/core/fields/renderers/association_renderer.rb +25 -0
- data/lib/plutonium/core/fields/renderers/basic_renderer.rb +27 -0
- data/lib/plutonium/core/fields/renderers/factory.rb +52 -0
- data/lib/plutonium/core/fields/renderers.rb +15 -0
- data/lib/plutonium/core/fields.rb +12 -0
- data/lib/plutonium/core/ui/collection.rb +14 -0
- data/lib/plutonium/core/ui/detail.rb +11 -0
- data/lib/plutonium/core/ui/form.rb +11 -0
- data/lib/plutonium/core/ui.rb +13 -0
- data/lib/plutonium/core.rb +16 -0
- data/lib/plutonium/helpers/action_buttons_helper.rb +32 -0
- data/lib/plutonium/helpers/application_helper.rb +22 -0
- data/lib/plutonium/helpers/attachment_helper.rb +62 -0
- data/lib/plutonium/helpers/content_helper.rb +66 -0
- data/lib/plutonium/helpers/display_helper.rb +83 -0
- data/lib/plutonium/helpers/form_helper.rb +24 -0
- data/lib/plutonium/helpers/menu_helper.rb +69 -0
- data/lib/plutonium/helpers/pagination_helper.rb +9 -0
- data/lib/plutonium/helpers/turbo_helper.rb +13 -0
- data/lib/plutonium/helpers/turbo_stream_actions_helper.rb +9 -0
- data/lib/plutonium/helpers.rb +31 -0
- data/lib/plutonium/initializers/TODO +2 -0
- data/lib/plutonium/initializers/pagy.rb +5 -0
- data/lib/plutonium/initializers/patches.rb +2 -0
- data/lib/plutonium/initializers/rabl.rb +60 -0
- data/lib/plutonium/initializers/simple_form.rb +405 -0
- data/lib/plutonium/lib/after_commit.rb +34 -0
- data/lib/plutonium/lib/bit_flags.rb +36 -0
- data/lib/plutonium/packaging/app.rb +125 -0
- data/lib/plutonium/packaging/feature.rb +18 -0
- data/lib/plutonium/packaging/package.rb +22 -0
- data/lib/plutonium/packaging.rb +9 -0
- data/lib/plutonium/policy/initializer.rb +22 -0
- data/lib/plutonium/policy/scope.rb +19 -0
- data/lib/plutonium/policy.rb +8 -0
- data/lib/plutonium/preserved__/field.rb +65 -0
- data/lib/plutonium/preserved__/input.rb +93 -0
- data/lib/plutonium/reactor/core.rb +61 -0
- data/lib/plutonium/reactor/resource_context.rb +15 -0
- data/lib/plutonium/reactor/resource_controller.rb +108 -0
- data/lib/plutonium/reactor/resource_interaction.rb +8 -0
- data/lib/plutonium/reactor/resource_policy.rb +105 -0
- data/lib/plutonium/reactor/resource_presenter.rb +42 -0
- data/lib/plutonium/reactor/resource_record.rb +123 -0
- data/lib/plutonium/reactor.rb +13 -0
- data/lib/plutonium/refinements/parameter_refinements.rb +26 -0
- data/lib/plutonium/simple_form_components/attachment_component.rb +77 -0
- data/lib/plutonium/simple_form_components/input_group_component.rb +14 -0
- data/lib/plutonium/version.rb +3 -0
- data/lib/plutonium.rb +31 -0
- data/plutonium.gemspec +47 -0
- data/public/.keep +0 -0
- data/public/plutonium-assets/application.css +24280 -0
- data/public/plutonium-assets/application.js +31420 -0
- data/public/plutonium-assets/fonts/bootstrap-icons.woff +0 -0
- data/public/plutonium-assets/fonts/bootstrap-icons.woff2 +0 -0
- data/public/plutonium-assets/logo.png +0 -0
- data/sig/plutonium.rbs +4 -0
- metadata +519 -0
@@ -0,0 +1,8 @@
|
|
1
|
+
# Used by the password reset feature
|
2
|
+
create_table :<%= table_prefix %>_password_reset_keys, id: false do |t|
|
3
|
+
t.<%= primary_key_type(nil) %> :id, primary_key: true
|
4
|
+
t.foreign_key :<%= table_prefix.pluralize %>, column: :id
|
5
|
+
t.string :key, null: false
|
6
|
+
t.datetime :deadline, null: false
|
7
|
+
t.datetime :email_last_sent, null: false, default: -> { "<%= current_timestamp %>" }
|
8
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# Used by the sms codes feature
|
2
|
+
create_table :<%= table_prefix %>_sms_codes, id: false do |t|
|
3
|
+
t.<%= primary_key_type(nil) %> :id, primary_key: true
|
4
|
+
t.foreign_key :<%= table_prefix.pluralize %>, column: :id
|
5
|
+
t.string :phone_number, null: false
|
6
|
+
t.integer :num_failures
|
7
|
+
t.string :code
|
8
|
+
t.datetime :code_issued_at, null: false, default: -> { "<%= current_timestamp %>" }
|
9
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Used by the account verification feature
|
2
|
+
create_table :<%= table_prefix %>_verification_keys, id: false do |t|
|
3
|
+
t.<%= primary_key_type(nil) %> :id, primary_key: true
|
4
|
+
t.foreign_key :<%= table_prefix.pluralize %>, column: :id
|
5
|
+
t.string :key, null: false
|
6
|
+
t.datetime :requested_at, null: false, default: -> { "<%= current_timestamp %>" }
|
7
|
+
t.datetime :email_last_sent, null: false, default: -> { "<%= current_timestamp %>" }
|
8
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Used by the verify login change feature
|
2
|
+
create_table :<%= table_prefix %>_login_change_keys, id: false do |t|
|
3
|
+
t.<%= primary_key_type(nil) %> :id, primary_key: true
|
4
|
+
t.foreign_key :<%= table_prefix.pluralize %>, column: :id
|
5
|
+
t.string :key, null: false
|
6
|
+
t.string :login, null: false
|
7
|
+
t.datetime :deadline, null: false
|
8
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Used by the webauthn feature
|
2
|
+
create_table :<%= table_prefix %>_webauthn_user_ids, id: false do |t|
|
3
|
+
t.<%= primary_key_type(nil) %> :id, primary_key: true
|
4
|
+
t.foreign_key :<%= table_prefix.pluralize %>, column: :id
|
5
|
+
t.string :webauthn_id, null: false
|
6
|
+
end
|
7
|
+
create_table :<%= table_prefix %>_webauthn_keys, primary_key: [:<%= table_prefix %>_id, :webauthn_id] do |t|
|
8
|
+
t.references :<%= table_prefix %>, foreign_key: true<%= primary_key_type(:type) %>
|
9
|
+
t.string :webauthn_id
|
10
|
+
t.string :public_key, null: false
|
11
|
+
t.integer :sign_count, null: false
|
12
|
+
t.datetime :last_use, null: false, default: -> { "<%= current_timestamp %>" }
|
13
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Used by the account expiration feature
|
2
|
+
create_table :<%= table_prefix %>_activity_times do
|
3
|
+
foreign_key :id, :<%= table_prefix.pluralize %>, primary_key: true, type: :Bignum
|
4
|
+
DateTime :last_activity_at, null: false
|
5
|
+
DateTime :last_login_at, null: false
|
6
|
+
DateTime :expired_at
|
7
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Used by the active sessions feature
|
2
|
+
create_table :<%= table_prefix %>_active_session_keys do
|
3
|
+
foreign_key :<%= table_prefix %>_id, :<%= table_prefix.pluralize %>, type: :Bignum
|
4
|
+
String :session_id
|
5
|
+
Time :created_at, null: false, default: Sequel::CURRENT_TIMESTAMP
|
6
|
+
Time :last_use, null: false, default: Sequel::CURRENT_TIMESTAMP
|
7
|
+
primary_key [:<%= table_prefix %>_id, :session_id]
|
8
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Used by the audit logging feature
|
2
|
+
create_table :<%= table_prefix %>_authentication_audit_logs do
|
3
|
+
primary_key :id, type: :Bignum
|
4
|
+
foreign_key :<%= table_prefix %>_id, :<%= table_prefix.pluralize %>, null: false, type: :Bignum
|
5
|
+
DateTime :at, null: false, default: Sequel::CURRENT_TIMESTAMP
|
6
|
+
String :message, null: false
|
7
|
+
<% case db.database_type -%>
|
8
|
+
<% when :postgres -%>
|
9
|
+
jsonb :metadata
|
10
|
+
<% when :sqlite, :mysql -%>
|
11
|
+
json :metadata
|
12
|
+
<% else -%>
|
13
|
+
String :metadata
|
14
|
+
<% end -%>
|
15
|
+
index [:<%= table_prefix %>_id, :at], name: :audit_<%= table_prefix %>_at_idx
|
16
|
+
index :at, name: :audit_at_idx
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<% if db.database_type == :postgres -%>
|
2
|
+
begin
|
3
|
+
run "CREATE EXTENSION IF NOT EXISTS citext"
|
4
|
+
rescue NoMethodError # migration is being reverted
|
5
|
+
end
|
6
|
+
|
7
|
+
<% end -%>
|
8
|
+
create_table :<%= table_prefix.pluralize %> do
|
9
|
+
primary_key :id, type: :Bignum
|
10
|
+
<% if db.database_type == :postgres -%>
|
11
|
+
citext :email, null: false
|
12
|
+
constraint :valid_email, email: /^[^,;@ \r\n]+@[^,@; \r\n]+\.[^,@; \r\n]+$/
|
13
|
+
<% else -%>
|
14
|
+
String :email, null: false
|
15
|
+
<% end -%>
|
16
|
+
Integer :status, null: false, default: 1
|
17
|
+
<% if db.supports_partial_indexes? -%>
|
18
|
+
index :email, unique: true, where: { status: [1, 2] }
|
19
|
+
<% else -%>
|
20
|
+
index :email, unique: true
|
21
|
+
<% end -%>
|
22
|
+
<% unless separate_passwords? -%>
|
23
|
+
String :password_hash
|
24
|
+
<% end -%>
|
25
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
# Used by the disallow password reuse feature
|
2
|
+
create_table :<%= table_prefix %>_previous_password_hashes do
|
3
|
+
primary_key :id, type: :Bignum
|
4
|
+
foreign_key :<%= table_prefix %>_id, :<%= table_prefix.pluralize %>, type: :Bignum
|
5
|
+
String :password_hash, null: false
|
6
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Used by the email auth feature
|
2
|
+
create_table :<%= table_prefix %>_email_auth_keys do
|
3
|
+
foreign_key :id, :<%= table_prefix.pluralize %>, primary_key: true, type: :Bignum
|
4
|
+
String :key, null: false
|
5
|
+
DateTime :deadline, null: false
|
6
|
+
DateTime :email_last_sent, null: false, default: Sequel::CURRENT_TIMESTAMP
|
7
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Used by the jwt refresh feature
|
2
|
+
create_table :<%= table_prefix %>_jwt_refresh_keys do
|
3
|
+
primary_key :id, type: :Bignum
|
4
|
+
foreign_key :<%= table_prefix %>_id, :<%= table_prefix.pluralize %>, null: false, type: :Bignum
|
5
|
+
String :key, null: false
|
6
|
+
DateTime :deadline, null: false
|
7
|
+
index :<%= table_prefix %>_id, name: :<%= table_prefix %>_jwt_rk_<%= table_prefix %>_id_idx
|
8
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Used by the lockout feature
|
2
|
+
create_table :<%= table_prefix %>_login_failures do
|
3
|
+
foreign_key :id, :<%= table_prefix.pluralize %>, primary_key: true, type: :Bignum
|
4
|
+
Integer :number, null: false, default: 1
|
5
|
+
end
|
6
|
+
create_table :<%= table_prefix %>_lockouts do
|
7
|
+
foreign_key :id, :<%= table_prefix.pluralize %>, primary_key: true, type: :Bignum
|
8
|
+
String :key, null: false
|
9
|
+
DateTime :deadline, null: false
|
10
|
+
DateTime :email_last_sent
|
11
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Used by the otp feature
|
2
|
+
create_table :<%= table_prefix %>_otp_keys do
|
3
|
+
foreign_key :id, :<%= table_prefix.pluralize %>, primary_key: true, type: :Bignum
|
4
|
+
String :key, null: false
|
5
|
+
Integer :num_failures, null: false, default: 0
|
6
|
+
Time :last_use, null: false, default: Sequel::CURRENT_TIMESTAMP
|
7
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Used by the password reset feature
|
2
|
+
create_table :<%= table_prefix %>_password_reset_keys do
|
3
|
+
foreign_key :id, :<%= table_prefix.pluralize %>, primary_key: true, type: :Bignum
|
4
|
+
String :key, null: false
|
5
|
+
DateTime :deadline, null: false
|
6
|
+
DateTime :email_last_sent, null: false, default: Sequel::CURRENT_TIMESTAMP
|
7
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
# Stores password hashes separate from the account table
|
2
|
+
create_table :<%= table_prefix %>_password_hashes do
|
3
|
+
primary_key :id, type: :Bignum
|
4
|
+
foreign_key :<%= table_prefix %>_id, :<%= table_prefix.pluralize %>, type: :Bignum
|
5
|
+
String :password_hash, null: false
|
6
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Used by the sms codes feature
|
2
|
+
create_table :<%= table_prefix %>_sms_codes do
|
3
|
+
foreign_key :id, :<%= table_prefix.pluralize %>, primary_key: true, type: :Bignum
|
4
|
+
String :phone_number, null: false
|
5
|
+
Integer :num_failures
|
6
|
+
String :code
|
7
|
+
DateTime :code_issued_at, null: false, default: Sequel::CURRENT_TIMESTAMP
|
8
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Used by the account verification feature
|
2
|
+
create_table :<%= table_prefix %>_verification_keys do
|
3
|
+
foreign_key :id, :<%= table_prefix.pluralize %>, primary_key: true, type: :Bignum
|
4
|
+
String :key, null: false
|
5
|
+
DateTime :requested_at, null: false, default: Sequel::CURRENT_TIMESTAMP
|
6
|
+
DateTime :email_last_sent, null: false, default: Sequel::CURRENT_TIMESTAMP
|
7
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Used by the verify login change feature
|
2
|
+
create_table :<%= table_prefix %>_login_change_keys do
|
3
|
+
foreign_key :id, :<%= table_prefix.pluralize %>, primary_key: true, type: :Bignum
|
4
|
+
String :key, null: false
|
5
|
+
String :login, null: false
|
6
|
+
DateTime :deadline, null: false
|
7
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Used by the webauthn feature
|
2
|
+
create_table :<%= table_prefix %>_webauthn_user_ids do
|
3
|
+
foreign_key :id, :<%= table_prefix.pluralize %>, primary_key: true, type: :Bignum
|
4
|
+
String :webauthn_id, null: false
|
5
|
+
end
|
6
|
+
create_table :<%= table_prefix %>_webauthn_keys do
|
7
|
+
foreign_key :<%= table_prefix %>_id, :<%= table_prefix.pluralize %>, type: :Bignum
|
8
|
+
String :webauthn_id
|
9
|
+
String :public_key, null: false
|
10
|
+
Integer :sign_count, null: false
|
11
|
+
Time :last_use, null: false, default: Sequel::CURRENT_TIMESTAMP
|
12
|
+
primary_key [:<%= table_prefix %>_id, :webauthn_id]
|
13
|
+
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
return unless defined?(Rodauth::Rails)
|
2
|
+
|
3
|
+
require "rails/generators/base"
|
4
|
+
require "rails/generators/active_record/migration"
|
5
|
+
require "erb"
|
6
|
+
require "digest"
|
7
|
+
|
8
|
+
require "#{__dir__}/concerns/configuration"
|
9
|
+
require "#{__dir__}/concerns/account_selector"
|
10
|
+
|
11
|
+
module Pu
|
12
|
+
module Rodauth
|
13
|
+
class MigrationGenerator < ::Rails::Generators::Base
|
14
|
+
include Concerns::Configuration
|
15
|
+
include Concerns::AccountSelector
|
16
|
+
|
17
|
+
source_root "#{__dir__}/templates"
|
18
|
+
|
19
|
+
desc "Generate migrations for supported features\n\n" \
|
20
|
+
"Supported Features\n" \
|
21
|
+
"=========================================\n" \
|
22
|
+
"#{MIGRATION_CONFIG.keys.sort.map(&:to_s).join "\n"}\n\n\n\n"
|
23
|
+
|
24
|
+
class_option :features, required: true, type: :array,
|
25
|
+
desc: "Rodauth features to create tables for (otp, sms_codes, single_session, account_expiration etc.)"
|
26
|
+
|
27
|
+
def validate_selected_features
|
28
|
+
if selected_features.empty?
|
29
|
+
say "No migration features specified!", :yellow
|
30
|
+
exit(1)
|
31
|
+
elsif (selected_features - valid_features).any?
|
32
|
+
say "No available migration for feature(s): #{(selected_features - valid_features).join(", ")}", :red
|
33
|
+
exit(1)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def create_rodauth_migration
|
38
|
+
migration_template "db/migrate/create_rodauth.rb", File.join(db_migrate_path, "#{migration_name}.rb")
|
39
|
+
end
|
40
|
+
|
41
|
+
def configure_rodauth_plugin_tables
|
42
|
+
in_root do
|
43
|
+
break unless table_prefix != "account" && File.exist?(plugin_filename)
|
44
|
+
|
45
|
+
gsub_file plugin_filename, /.*# accounts_table.*\n/, "" if selected_features.include? :base
|
46
|
+
|
47
|
+
migration_overrides.sort.reverse_each do |key, value|
|
48
|
+
override = indent "#{key} :#{value}\n", 4
|
49
|
+
insert_into_file plugin_filename, override,
|
50
|
+
after: /.*# Change prefix of table and.*\n/
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def show_instructions
|
56
|
+
in_root do
|
57
|
+
break if table_prefix == "account" || File.exist?(plugin_filename)
|
58
|
+
|
59
|
+
configuration = migration_overrides
|
60
|
+
.map { |config, format| "#{config} :#{format}" }
|
61
|
+
.join("\n")
|
62
|
+
.indent(2)
|
63
|
+
|
64
|
+
say "\n\nAdd the following to your Rodauth plugin configure block:", :blue
|
65
|
+
say "\n\n#{configuration}\n\n\n\n", :magenta
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def plugin_filename
|
72
|
+
"app/misc/#{table_prefix}_rodauth_plugin.rb"
|
73
|
+
end
|
74
|
+
|
75
|
+
def migration_name
|
76
|
+
@migration_name ||= begin
|
77
|
+
max_len = 150
|
78
|
+
migration_name = options[:migration_name] || ["create_rodauth", table_prefix, *selected_features].join("_")
|
79
|
+
if migration_name.length <= max_len
|
80
|
+
migration_name
|
81
|
+
else
|
82
|
+
[migration_name.first(max_len), Digest::SHA256.hexdigest(migration_name).first(10)].join("_")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def selected_features
|
88
|
+
@selected_features ||= begin
|
89
|
+
features = options[:features]
|
90
|
+
features.unshift "base" if features.delete "base"
|
91
|
+
features.map(&:to_sym)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def migration_overrides
|
96
|
+
@migration_overrides ||= migration_config.values_at(*selected_features)
|
97
|
+
.flat_map(&:to_a)
|
98
|
+
.filter { |config, format| config.ends_with? "_table" }
|
99
|
+
.map { |config, format| [config, (format % {plural: table_prefix.pluralize, singular: table_prefix})] }
|
100
|
+
.to_h
|
101
|
+
.compact
|
102
|
+
end
|
103
|
+
|
104
|
+
def migration_content
|
105
|
+
selected_features
|
106
|
+
.map { |feature| File.read(migration_chunk(feature)) }
|
107
|
+
.map { |content| erb_eval(content) }
|
108
|
+
.join("\n")
|
109
|
+
.indent(4)
|
110
|
+
end
|
111
|
+
|
112
|
+
def erb_eval(content)
|
113
|
+
ERB.new(content, trim_mode: "-").result(binding)
|
114
|
+
end
|
115
|
+
|
116
|
+
def separate_passwords?
|
117
|
+
selected_features.include? :separate_passwords
|
118
|
+
end
|
119
|
+
|
120
|
+
def migration_chunk(feature)
|
121
|
+
"#{MIGRATION_DIR}/#{feature}.erb"
|
122
|
+
end
|
123
|
+
|
124
|
+
def valid_features
|
125
|
+
Dir["#{MIGRATION_DIR}/*.erb"].map { |filename| File.basename(filename, ".erb").to_sym }
|
126
|
+
end
|
127
|
+
|
128
|
+
if defined?(::ActiveRecord::Railtie) # Active Record
|
129
|
+
include ::ActiveRecord::Generators::Migration
|
130
|
+
|
131
|
+
MIGRATION_DIR = "#{__dir__}/migration/active_record"
|
132
|
+
|
133
|
+
def activerecord_adapter
|
134
|
+
if ActiveRecord::Base.respond_to?(:connection_db_config)
|
135
|
+
ActiveRecord::Base.connection_db_config.adapter
|
136
|
+
else
|
137
|
+
ActiveRecord::Base.connection_config.fetch(:adapter)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def primary_key_type(key = :id)
|
142
|
+
generators = ::Rails.application.config.generators
|
143
|
+
column_type = generators.options[:active_record][:primary_key_type]
|
144
|
+
|
145
|
+
if key
|
146
|
+
", #{key}: :#{column_type}" if column_type
|
147
|
+
else
|
148
|
+
column_type || default_primary_key_type
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def default_primary_key_type
|
153
|
+
if ActiveRecord.version >= Gem::Version.new("5.1") && activerecord_adapter != "sqlite3"
|
154
|
+
:bigint
|
155
|
+
else
|
156
|
+
:integer
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
# Active Record 7+ sets default precision to 6 for timestamp columns,
|
161
|
+
# so we need to ensure we match this when setting the default value.
|
162
|
+
def current_timestamp
|
163
|
+
if ActiveRecord.version >= Gem::Version.new("7.0") && ["mysql2", "trilogy"].include?(activerecord_adapter) && ActiveRecord::Base.connection.supports_datetime_with_precision?
|
164
|
+
"CURRENT_TIMESTAMP(6)"
|
165
|
+
else
|
166
|
+
"CURRENT_TIMESTAMP"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
else # Sequel
|
170
|
+
include ::Rails::Generators::Migration
|
171
|
+
|
172
|
+
MIGRATION_DIR = "#{__dir__}/migration/sequel"
|
173
|
+
|
174
|
+
def self.next_migration_number(dirname)
|
175
|
+
next_migration_number = current_migration_number(dirname) + 1
|
176
|
+
[Time.now.utc.strftime("%Y%m%d%H%M%S"), format("%.14d", next_migration_number)].max
|
177
|
+
end
|
178
|
+
|
179
|
+
def db_migrate_path
|
180
|
+
"db/migrate"
|
181
|
+
end
|
182
|
+
|
183
|
+
def db
|
184
|
+
db = ::Sequel::DATABASES.first if defined?(::Sequel)
|
185
|
+
db or fail Rodauth::Rails::Error, "missing Sequel database connection"
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
===============================================================================
|
2
|
+
|
3
|
+
Depending on your application's configuration some manual setup may be required:
|
4
|
+
|
5
|
+
1. Ensure you have defined default url options in your environments files. Here
|
6
|
+
is an example of default_url_options appropriate for a development environment
|
7
|
+
in config/environments/development.rb:
|
8
|
+
|
9
|
+
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
10
|
+
|
11
|
+
In production, :host should be set to the actual host of your application.
|
12
|
+
|
13
|
+
* Required for all applications. *
|
14
|
+
|
15
|
+
2. Ensure you have defined root_url to *something* in your config/routes.rb.
|
16
|
+
For example:
|
17
|
+
|
18
|
+
root to: "home#index"
|
19
|
+
|
20
|
+
* Not required for API-only Applications *
|
21
|
+
|
22
|
+
3. Ensure you have flash messages in app/views/layouts/application.html.erb.
|
23
|
+
For example:
|
24
|
+
|
25
|
+
<% if notice %>
|
26
|
+
<div class="alert alert-success"><%= notice %></div>
|
27
|
+
<% end %>
|
28
|
+
<% if alert %>
|
29
|
+
<div class="alert alert-danger"><%= alert %></div>
|
30
|
+
<% end %>
|
31
|
+
|
32
|
+
* Not required for API-only Applications *
|
33
|
+
|
34
|
+
4. Titles for Rodauth pages are available via @page_title instance variable
|
35
|
+
by default, you can use it in your layout file:
|
36
|
+
|
37
|
+
<head>
|
38
|
+
<title><%= @page_title || "Default title" %></title>
|
39
|
+
...
|
40
|
+
</head>
|
41
|
+
|
42
|
+
* Not required *
|
43
|
+
|
44
|
+
5. You can copy Rodauth views (for customization) to your app by running:
|
45
|
+
|
46
|
+
rails g rodauth:views # default bootstrap views
|
47
|
+
|
48
|
+
rails g rodauth:views --css=tailwind # tailwind views (requires @tailwindcss/forms plugin)
|
49
|
+
|
50
|
+
* Not required *
|
51
|
+
|
52
|
+
===============================================================================
|
@@ -0,0 +1,62 @@
|
|
1
|
+
class RodauthMailer < ApplicationMailer
|
2
|
+
default to: -> { @rodauth.email_to }
|
3
|
+
|
4
|
+
def verify_account(name, account_id, key)
|
5
|
+
@rodauth = rodauth(name, account_id) { @verify_account_key_value = key }
|
6
|
+
@account = @rodauth.rails_account
|
7
|
+
|
8
|
+
mail subject: @rodauth.email_subject_prefix + @rodauth.verify_account_email_subject
|
9
|
+
end
|
10
|
+
|
11
|
+
def reset_password(name, account_id, key)
|
12
|
+
@rodauth = rodauth(name, account_id) { @reset_password_key_value = key }
|
13
|
+
@account = @rodauth.rails_account
|
14
|
+
|
15
|
+
mail subject: @rodauth.email_subject_prefix + @rodauth.reset_password_email_subject
|
16
|
+
end
|
17
|
+
|
18
|
+
def verify_login_change(name, account_id, key)
|
19
|
+
@rodauth = rodauth(name, account_id) { @verify_login_change_key_value = key }
|
20
|
+
@account = @rodauth.rails_account
|
21
|
+
@new_email = @account.login_change_key.login
|
22
|
+
|
23
|
+
mail to: @new_email, subject: @rodauth.email_subject_prefix + @rodauth.verify_login_change_email_subject
|
24
|
+
end
|
25
|
+
|
26
|
+
def change_password_notify(name, account_id)
|
27
|
+
@rodauth = rodauth(name, account_id)
|
28
|
+
@account = @rodauth.rails_account
|
29
|
+
|
30
|
+
mail subject: @rodauth.email_subject_prefix + @rodauth.password_changed_email_subject
|
31
|
+
end
|
32
|
+
|
33
|
+
def reset_password_notify(name, account_id)
|
34
|
+
@rodauth = rodauth(name, account_id)
|
35
|
+
@account = @rodauth.rails_account
|
36
|
+
|
37
|
+
mail subject: @rodauth.email_subject_prefix + @rodauth.reset_password_notify_email_subject
|
38
|
+
end
|
39
|
+
|
40
|
+
def email_auth(name, account_id, key)
|
41
|
+
@rodauth = rodauth(name, account_id) { @email_auth_key_value = key }
|
42
|
+
@account = @rodauth.rails_account
|
43
|
+
|
44
|
+
mail subject: @rodauth.email_subject_prefix + @rodauth.email_auth_email_subject
|
45
|
+
end
|
46
|
+
|
47
|
+
def unlock_account(name, account_id, key)
|
48
|
+
@rodauth = rodauth(name, account_id) { @unlock_account_key_value = key }
|
49
|
+
@account = @rodauth.rails_account
|
50
|
+
|
51
|
+
mail subject: @rodauth.email_subject_prefix + @rodauth.unlock_account_email_subject
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def rodauth(name, account_id, &block)
|
57
|
+
instance = RodauthApp.rodauth(name).allocate
|
58
|
+
instance.instance_eval { @account = account_ds(account_id).first! }
|
59
|
+
instance.instance_eval(&block) if block
|
60
|
+
instance
|
61
|
+
end
|
62
|
+
end
|