|
|
|
@@ -1,8 +1,5 @@ |
|
|
|
class UsersController < ApplicationController |
|
|
|
def create |
|
|
|
return head :unprocessable_entity if request.remote_ip.blank? |
|
|
|
return head :forbidden if ip_address_banned? |
|
|
|
|
|
|
|
user = nil |
|
|
|
User.transaction do |
|
|
|
user = User.create!(inheritance_code: SecureRandom.uuid, role: :guest) |
|
|
|
@@ -15,9 +12,6 @@ class UsersController < ApplicationController |
|
|
|
end |
|
|
|
|
|
|
|
def verify |
|
|
|
return head :unprocessable_entity if request.remote_ip.blank? |
|
|
|
return head :forbidden if ip_address_banned? |
|
|
|
|
|
|
|
user = User.find_by(inheritance_code: params[:code]) |
|
|
|
return render json: { valid: false } unless user |
|
|
|
return head :forbidden if user.banned? |
|
|
|
@@ -65,11 +59,4 @@ class UsersController < ApplicationController |
|
|
|
|
|
|
|
UserIp.create_or_find_by!(user:, ip_address:) |
|
|
|
end |
|
|
|
|
|
|
|
def ip_address_banned? |
|
|
|
ip_address = IpAddress.find_by(ip_address: IPAddr.new(request.remote_ip).hton) |
|
|
|
return false unless ip_address |
|
|
|
|
|
|
|
ip_address.banned? |
|
|
|
end |
|
|
|
end |