mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FIX: handle error for duplicate email_in address
This commit is contained in:
@ -87,6 +87,9 @@ class CategoriesController < ApplicationController
|
||||
if category_params.key? :email_in and category_params[:email_in].length == 0
|
||||
# properly null the value so the database constrain doesn't catch us
|
||||
category_params[:email_in] = nil
|
||||
elsif category_params.key? :email_in and existing_category = Category.find_by(email_in: category_params[:email_in]) and existing_category.id != @category.id
|
||||
# check if email_in address is already in use for other category
|
||||
return render_json_error I18n.t('category.errors.email_in_already_exist', {email_in: category_params[:email_in], category_name: existing_category.name})
|
||||
end
|
||||
|
||||
category_params.delete(:position)
|
||||
|
Reference in New Issue
Block a user