Class: Auth::CustomerRegistrationsController
- Inherits:
-
Devise::RegistrationsController
- Object
- Devise::RegistrationsController
- Auth::CustomerRegistrationsController
- 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
-
#create ⇒ Object
Override Devise's
createto queue the registration conversion for the next globals.json response. -
#edit ⇒ void
GET /accounts/edit — account edit (password change) form.
-
#edit_email ⇒ void
GET /accounts/edit_email — form for changing login/email.
-
#set_report_errors_for ⇒ Object
protected
This controller instance set the model to use for detecting errors in the application_controller#write_flash_to_cookie method.
-
#update ⇒ void
PUT /accounts — changes the password after re-verifying the current one.
-
#update_email ⇒ void
PUT /accounts/update_email — changes login/email after re-verifying the current password.
Methods included from Controllers::MasqueradeGuarded
block_while_masquerading, #masquerade_blocks?
Instance Method Details
#create ⇒ Object
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.
28 29 30 |
# File 'app/controllers/auth/customer_registrations_controller.rb', line 28 def create super { |resource| queue_registration_event(resource) } end |
#edit ⇒ void
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(current_account.id) end |
#edit_email ⇒ void
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(current_account.id) render :edit_email end |
#set_report_errors_for ⇒ Object (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 |
#update ⇒ void
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(current_account.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' bypass_sign_in @account :notice, :updated redirect_to my_account_path 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_email ⇒ void
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(current_account.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]) :notice, :updated redirect_to my_account_path 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 |