Class: Auth::CustomerRegistrationsController

Inherits:
Devise::RegistrationsController
  • Object
show all
Includes:
Controllers::MasqueradeGuarded
Defined in:
app/controllers/auth/customer_registrations_controller.rb

Overview

Constant Summary

Constants included from Controllers::MasqueradeGuarded

Controllers::MasqueradeGuarded::DEFAULT_BLOCK_MESSAGE

Instance Method Summary collapse

Methods included from Controllers::MasqueradeGuarded

block_while_masquerading, #masquerade_blocks?

Instance Method Details

#createObject

Override Devise's create to queue the registration conversion for the
next globals.json response. The session-backed queue is drained only after
consent configuration has initialized the analytics SDKs on the redirect
target, so this event cannot race OpenAI's asynchronously loaded pixel.

We yield through super's built-in block hook so Devise still owns the
save / sign-in / redirect lifecycle — we just observe the persisted
resource and queue the event when it's a real signup.

See Also:



28
29
30
# File 'app/controllers/auth/customer_registrations_controller.rb', line 28

def create
  super { |resource| queue_registration_event(resource) }
end

#editvoid

This method returns an undefined value.

GET /accounts/edit — account edit (password change) form.



66
67
68
# File 'app/controllers/auth/customer_registrations_controller.rb', line 66

def edit
  @account = Account.find(.id)
end

#edit_emailvoid

This method returns an undefined value.

GET /accounts/edit_email — form for changing login/email.



35
36
37
38
# File 'app/controllers/auth/customer_registrations_controller.rb', line 35

def edit_email
  @account = Account.find(.id)
  render :edit_email
end

#set_report_errors_forObject (protected)

This controller instance set the model to use for detecting errors in the application_controller#write_flash_to_cookie method.



108
109
110
# File 'app/controllers/auth/customer_registrations_controller.rb', line 108

def set_report_errors_for
  @report_errors_for = [resource]
end

#updatevoid

This method returns an undefined value.

PUT /accounts — changes the password after re-verifying the current one.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'app/controllers/auth/customer_registrations_controller.rb', line 73

def update
  @account = Account.find(.id)
  # puts "params.inspect: #{params.inspect}"
  pass = params[:account].delete(:current_password)
  if @account.encrypted_password.blank? || @account.valid_password?(pass)
    if params[:account][:password] && (params[:account][:password] == params[:account][:password_confirmation])
      if @account.update(params[:account])
        # Account#notify_credentials_changed sends the password-change
        # email via after_update_commit (covers controller updates,
        # password reset by token, CRM admin updates).
        # Sign in the user by passing validation since their password just changed.
        # Tag the AuthTrail row honestly: bypass_sign_in fires Warden's
        # after_set_user without a winning strategy, so AuthTrail would
        # otherwise mislabel this as `database_authenticatable` (no
        # password was actually re-validated here).
        request.env[AUTHTRAIL_TRACKED_STRATEGY_ENV_KEY] = 'password_change_bypass'
         @account
        set_flash_message :notice, :updated
        redirect_to 
      else
        render :edit, status: :unprocessable_content
      end
    else
      flash.now[:error] = 'Uh oh! Password does not match confirmation.'
      render :edit, status: :unprocessable_content
    end
  else
    flash.now[:error] = 'Uh oh! Incorrect password. Please enter your current password to change your password.'
    render :edit, status: :unprocessable_content
  end
end

#update_emailvoid

This method returns an undefined value.

PUT /accounts/update_email — changes login/email after re-verifying the
current password.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/controllers/auth/customer_registrations_controller.rb', line 44

def update_email
  @account = Account.find(.id)
  pass = params[:account].delete(:password)
  if (@account.encrypted_password.blank? && @account.authentications.present?) || @account.valid_password?(pass)
    # Account#notify_credentials_changed handles email/login change
    # notifications via after_update_commit, so every code path that
    # mutates these columns notifies — not just this controller.
    if @account.update_without_password(params[:account])
      set_flash_message :notice, :updated
      redirect_to 
    else
      render :edit_email, status: :unprocessable_content
    end
  else
    flash.now[:error] = 'Uh oh! Incorrect password. Please enter your current password to change your e-mail/login.'
    render :edit_email, status: :unprocessable_content
  end
end