mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-08 22:56:06 +00:00
This may lead to more error reports than we want to see. A not existing email address may cause Bugsnag to be notified. If this happens, we can rescue form these specific errors and only report the rest.
45 lines
1.1 KiB
Ruby
45 lines
1.1 KiB
Ruby
require 'open_food_network/error_logger'
|
|
|
|
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 => error
|
|
OpenFoodNetwork::ErrorLogger.notify(error)
|
|
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
|