diff --git a/backend/app/controllers/users_controller.rb b/backend/app/controllers/users_controller.rb index 048e032..a144593 100644 --- a/backend/app/controllers/users_controller.rb +++ b/backend/app/controllers/users_controller.rb @@ -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 diff --git a/backend/app/models/ip_address.rb b/backend/app/models/ip_address.rb index 5279369..e51e3ac 100644 --- a/backend/app/models/ip_address.rb +++ b/backend/app/models/ip_address.rb @@ -5,6 +5,6 @@ class IpAddress < ApplicationRecord has_many :users, through: :user_ips def banned? = banned_at.present? - def ban! = banned? or update!(banned_at: Time.current) + def ban! = banned? || update!(banned_at: Time.current) def unban! = update!(banned_at: nil) end diff --git a/backend/app/models/user.rb b/backend/app/models/user.rb index 5f4bab5..f974adf 100644 --- a/backend/app/models/user.rb +++ b/backend/app/models/user.rb @@ -22,6 +22,6 @@ class User < ApplicationRecord def gte_member? = member? || admin? def banned? = banned_at.present? - def ban! = banned? or update!(banned_at: Time.current) + def ban! = banned? || update!(banned_at: Time.current) def unban! = update!(banned_at: nil) end