forked from fixin.me/fixin.me
Introduce config.skip_email_confirmation in application.rb.dist. When set to true, new registrations are automatically confirmed without requiring email verification — useful for installations where outgoing email is not configured or for development/testing. Implemented by calling skip_confirmation! in build_resource before the record is saved, so no confirmation email is ever sent. Also fix ArgumentError raised in length validations when type_for_attribute(:column).limit returns nil, which happens with SQLite for string columns that have no explicit limit in the migration. Guard with || Float::INFINITY so the validation is effectively skipped when the database imposes no limit. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
35 lines
1.0 KiB
Ruby
35 lines
1.0 KiB
Ruby
class RegistrationsController < Devise::RegistrationsController
|
|
before_action :authenticate_user!, only: [:edit, :update, :destroy]
|
|
|
|
def destroy
|
|
# TODO: Disallow/disable deletion for last admin account; update :edit view
|
|
super
|
|
end
|
|
|
|
protected
|
|
|
|
def build_resource(hash = {})
|
|
super
|
|
# Skip the email confirmation step when the admin has opted out of it via
|
|
# config.skip_email_confirmation in application.rb. The account becomes
|
|
# active immediately so the user can sign in right after registering.
|
|
resource.skip_confirmation! if Rails.application.config.skip_email_confirmation
|
|
end
|
|
|
|
def update_resource(resource, params)
|
|
# Based on update_with_password()
|
|
if params[:password].blank?
|
|
params.delete(:password)
|
|
params.delete(:password_confirmation) if params[:password_confirmation].blank?
|
|
end
|
|
|
|
result = resource.update(params)
|
|
resource.clean_up_passwords
|
|
result
|
|
end
|
|
|
|
def after_inactive_sign_up_path_for(resource)
|
|
new_user_session_path
|
|
end
|
|
end
|