Class: Supabase::Rails::RegistrationsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/supabase/rails/registrations_controller.rb

Overview

Email + password sign-up. Two-branch happy path:

* `result.value.session` is non-nil → auto-sign-in is enabled on the
  Supabase project → user is signed in immediately.
* `result.value.session` is nil → email-confirmation is required →
  render a "Check your inbox" notice and route back to the sign-in
  page so the user lands there after clicking the confirmation link.

On a 4xx upstream failure Authentication#supabase_sign_up surfaces the mapped AuthError so the host can show specific UI for ‘WEAK_PASSWORD` (422) while masking other 4xx errors to a generic “Invalid credentials” (FR-W7 / US-012). 5xx flashes a generic message.

Instance Method Summary collapse

Methods included from Authentication

#after_authentication_url, #authenticate_with_supabase, #authenticated?, #current_user, expose_current_user?, railtie_config, redact_email, #request_authentication, #require_authentication, #start_new_session_for, #store_location_for_redirect, #stored_location_for_redirect, #supabase_exchange_code_for_session, #supabase_resend, #supabase_reset_password, #supabase_sign_in_with_oauth, #supabase_sign_in_with_otp, #supabase_sign_in_with_password, #supabase_sign_up, #supabase_update_user, #supabase_verify_otp, #terminate_session

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/supabase/rails/registrations_controller.rb', line 22

def create
  result = (email: params[:email], password: params[:password])

  if result.success?
    if registered_session_present?(result.value)
      redirect_to after_authentication_url,
                  notice: I18n.t("supabase.rails.registrations.created")
    else
      redirect_to new_session_path,
                  notice: I18n.t("supabase.rails.registrations.pending_confirmation")
    end
  else
    flash.now[:alert] = result.error.message
    render :new, status: :unprocessable_entity
  end
end

#newObject



20
# File 'app/controllers/supabase/rails/registrations_controller.rb', line 20

def new; end