Having trouble with users registering using our own company email address.
Example: I work at twitter. Users trying to use: user@twitter.com as their email address.
What would I add to the user model to block this from happening?
Having trouble with users registering using our own company email address.
Example: I work at twitter. Users trying to use: user@twitter.com as their email address.
What would I add to the user model to block this from happening?
Try using a custom validation. Here is a super slimmed down example. You may want a bit more power, but this should get you started.
class User < ActiveRecord::Base
validates :email, blacklist: true
end
class BlacklistValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add attribute, (options[:message] || "is not a valid email") if
value =~ /twitter\.com/
end
end