Class: Supabase::Rails::PasswordsController

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

Overview

Password reset (two-step flow):

* `new` / `create` — user requests a reset email. Supabase Auth
  handles the email content + tokenized link.
* `edit` / `update` — user lands here after clicking the recovery
  link. The recovery deep-link delivers them with an authenticated
  session in the encrypted cookie, so {#update} can call
  {Supabase::Rails::Authentication#supabase_update_user} to set the
  new password (which goes through the session-seeded auth client
  per FR-W6 / US-016).

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



20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/supabase/rails/passwords_controller.rb', line 20

def create
  result = supabase_reset_password(email: params[:email])

  if result.success?
    redirect_to new_session_path,
                notice: I18n.t("supabase.rails.passwords.reset_sent")
  else
    flash.now[:alert] = result.error.message
    render :new, status: :unprocessable_entity
  end
end

#editObject



32
# File 'app/controllers/supabase/rails/passwords_controller.rb', line 32

def edit; end

#newObject



18
# File 'app/controllers/supabase/rails/passwords_controller.rb', line 18

def new; end

#updateObject



34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/supabase/rails/passwords_controller.rb', line 34

def update
  result = supabase_update_user(password: params[:password])

  if result.success?
    redirect_to new_session_path,
                notice: I18n.t("supabase.rails.passwords.updated")
  else
    flash.now[:alert] = result.error.message
    render :edit, status: :unprocessable_entity
  end
end