Skip to content

Commit

Permalink
Improve UX for error signing up from proxies.
Browse files Browse the repository at this point in the history
  • Loading branch information
nottalulah committed Oct 4, 2024
1 parent eb3c6a1 commit 63bd149
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 0 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def profile
end

def create
raise User::PrivilegeError if Danbooru::IpAddress.new(request.remote_ip).is_proxy?
user_verifier = UserVerifier.new(CurrentUser.user, request)

@user = authorize User.new(
Expand Down
7 changes: 7 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ module Levels
validates :comment_threshold, inclusion: { in: (-100..5) }
validate :validate_custom_css, if: :custom_style_changed?
validate :validate_add_extra_data_attributes, unless: :new_record?
validate :validate_not_signing_up_from_proxy, if: :new_record?
before_validation :normalize_blacklisted_tags
before_create :promote_to_owner_if_first_user

Expand Down Expand Up @@ -231,6 +232,12 @@ def validate_add_extra_data_attributes
end
end

def validate_not_signing_up_from_proxy
if last_ip_addr&.is_proxy?
errors.add(:base, "Sign ups are not allowed from that IP address.")
end
end

def name_errors
UserNameValidator.new(attributes: [:name], skip_uniqueness: true).validate(self)
errors
Expand Down
1 change: 1 addition & 0 deletions config/initializers/inflections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
inflect.acronym "AI"
inflect.acronym "SFTP"
inflect.acronym "TOTP"
inflect.acronym "IP"
inflect.acronym "VAE"
inflect.acronym "UI"
inflect.acronym "RNG"
Expand Down

0 comments on commit 63bd149

Please sign in to comment.