FIX: hide user id when hide_email_address_taken (#11417)
We should always hide user_id in response when `hide_email_address_taken` setting is enabled. Currently, it can be used to determine if the email was used or not.
This commit is contained in:
parent
28feb7c2ff
commit
d5ba854c91
|
@ -647,8 +647,7 @@ class UsersController < ApplicationController
|
|||
success: true,
|
||||
active: user.active?,
|
||||
message: activation.message,
|
||||
user_id: user.id
|
||||
}
|
||||
}.merge(SiteSetting.hide_email_address_taken ? {} : { user_id: user.id })
|
||||
elsif SiteSetting.hide_email_address_taken && user.errors[:primary_email]&.include?(I18n.t('errors.messages.taken'))
|
||||
session["user_created_message"] = activation.success_message
|
||||
|
||||
|
@ -658,9 +657,8 @@ class UsersController < ApplicationController
|
|||
|
||||
render json: {
|
||||
success: true,
|
||||
active: user.active?,
|
||||
message: activation.success_message,
|
||||
user_id: user.id
|
||||
active: false,
|
||||
message: activation.success_message
|
||||
}
|
||||
else
|
||||
errors = user.errors.to_hash
|
||||
|
|
|
@ -762,6 +762,18 @@ describe UsersController do
|
|||
json = response.parsed_body
|
||||
expect(json['active']).to be_falsey
|
||||
expect(json['message']).to eq(I18n.t("login.activate_email", email: post_user_params[:email]))
|
||||
expect(json['user_id']).not_to be_present
|
||||
|
||||
existing.destroy!
|
||||
expect {
|
||||
post_user
|
||||
}.to change { User.count }
|
||||
expect(response.status).to eq(200)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json['active']).to be_falsey
|
||||
expect(json['message']).to eq(I18n.t("login.activate_email", email: post_user_params[:email]))
|
||||
expect(json['user_id']).not_to be_present
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue