Disallow email addresses in Neopets usernames

People are evading the filtering in the description and they know it!
Boooo!
This commit is contained in:
Emi Matchu 2025-06-22 11:16:26 -07:00
parent 0e32eb5d8f
commit 903d6a8a19
3 changed files with 11 additions and 2 deletions

View file

@ -754,6 +754,11 @@
contactField.val(connection.id); contactField.val(connection.id);
submitContactForm(); submitContactForm();
}, },
error: function (xhr) {
var data = JSON.parse(xhr.responseText);
var fullMessage = data.full_error_messages.join("\n");
alert("Oops, we couldn't save this username!\n\n" + fullMessage);
},
}); });
} }
} else { } else {

View file

@ -5,7 +5,10 @@ class NeopetsConnectionsController < ApplicationController
if connection.save if connection.save
render json: connection render json: connection
else else
render json: {error: 'failure'}, status: :internal_server_error render json: {
errors: connection.errors,
full_error_messages: connection.errors.map(&:full_message)
}, status: :bad_request
end end
end end

View file

@ -1,5 +1,6 @@
class NeopetsConnection < ApplicationRecord class NeopetsConnection < ApplicationRecord
belongs_to :user belongs_to :user
validates :neopets_username, uniqueness: {scope: :user_id} validates :neopets_username, uniqueness: {scope: :user_id},
format: { without: /@/, message: 'must not be an email address, for user safety' }
end end