Refactor user registrations controller, early return to reduce indentation

This commit is contained in:
luisramos0
2018-12-18 15:26:49 +00:00
parent e274442d77
commit a9222665b8

View File

@@ -8,22 +8,22 @@ class UserRegistrationsController < Spree::UserRegistrationsController
# 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
unless resource.save
return render_error(@user.errors)
end
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
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
else
render_error(@user.errors)
end
rescue StandardError => error
OpenFoodNetwork::ErrorLogger.notify(error)