mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-05 07:19:14 +00:00
The most common failure would happen when sending the confirmation email triggered by `user.save`. We rescue any errors here and give feedback to the user. This allows for immediate feedback when the user types an email address that is not accepted by our mail server or the email setup is not configured properly.
42 lines
1.0 KiB
Ruby
42 lines
1.0 KiB
Ruby
class UserRegistrationsController < Spree::UserRegistrationsController
|
|
before_filter :set_checkout_redirect, only: :create
|
|
|
|
# POST /resource/sign_up
|
|
def create
|
|
@user = build_resource(params[:spree_user])
|
|
if resource.save
|
|
session[:spree_user_signup] = true
|
|
session[:confirmation_return_url] = params[:return_url]
|
|
associate_user
|
|
|
|
respond_to do |format|
|
|
format.html do
|
|
set_flash_message(:success, :signed_up_but_unconfirmed)
|
|
redirect_to after_sign_in_path_for(@user)
|
|
end
|
|
format.js do
|
|
render json: { email: @user.email }
|
|
end
|
|
end
|
|
else
|
|
render_error(@user.errors)
|
|
end
|
|
rescue StandardError
|
|
render_error(message: I18n.t('devise.user_registrations.spree_user.unknown_error'))
|
|
end
|
|
|
|
private
|
|
|
|
def render_error(errors = {})
|
|
clean_up_passwords(resource)
|
|
respond_to do |format|
|
|
format.html do
|
|
render :new
|
|
end
|
|
format.js do
|
|
render json: errors, status: :unauthorized
|
|
end
|
|
end
|
|
end
|
|
end
|