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 flag the redirect target for analytics pixel fire. - #edit ⇒ Object
- #edit_email ⇒ Object
-
#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 ⇒ Object
- #update_email ⇒ Object
Methods included from Controllers::MasqueradeGuarded
block_while_masquerading, #masquerade_blocks?
Instance Method Details
#create ⇒ Object
Override Devise's create to flag the redirect target for analytics
pixel fire. The flash key is read by app/views/shared/_tracking_init.html.erb
which renders analytics_event_meta_tag(:registration_completed). That
meta tag is then picked up by Analytics.boot() on turbo:load and
dispatched to the GA4/Facebook/OpenAI Ads pixel fan-out.
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 set the flash when it's a real signup.
28 29 30 31 32 |
# File 'app/controllers/auth/customer_registrations_controller.rb', line 28 def create super do |resource| flash[:registration_completed] = true if resource.persisted? end end |
#edit ⇒ Object
58 59 60 |
# File 'app/controllers/auth/customer_registrations_controller.rb', line 58 def edit @account = Account.find(current_account.id) end |
#edit_email ⇒ Object
34 35 36 37 |
# File 'app/controllers/auth/customer_registrations_controller.rb', line 34 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.
97 98 99 |
# File 'app/controllers/auth/customer_registrations_controller.rb', line 97 def set_report_errors_for @report_errors_for = [resource] end |
#update ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/controllers/auth/customer_registrations_controller.rb', line 62 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 ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/auth/customer_registrations_controller.rb', line 39 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 |