Class: Supabase::Rails::SessionsController

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

Overview

Email + password sign-in / sign-out. Subclassed in the host app by the install generator (FR-W12) so updates to flash copy, error handling, redirect destinations, etc. ship via ‘bundle update`. Hosts override any action by redefining it in the subclass.

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



14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/supabase/rails/sessions_controller.rb', line 14

def create
  if (supabase_session = authenticate_with_supabase(email: params[:email], password: params[:password]))
    start_new_session_for(supabase_session)
    redirect_to after_authentication_url,
                notice: I18n.t("supabase.rails.sessions.created")
  else
    flash.now[:alert] = I18n.t("supabase.rails.sessions.invalid")
    render :new, status: :unauthorized
  end
end

#destroyObject



25
26
27
28
29
# File 'app/controllers/supabase/rails/sessions_controller.rb', line 25

def destroy
  terminate_session
  redirect_to root_path,
              notice: I18n.t("supabase.rails.sessions.destroyed")
end

#newObject



12
# File 'app/controllers/supabase/rails/sessions_controller.rb', line 12

def new; end