separated out ip ban logic from regular bans, users can no longer register if an ip ban is in place

This commit is contained in:
albert
2010-03-18 17:55:57 -04:00
parent dcf8d0df4c
commit e46bfb3d76
12 changed files with 124 additions and 33 deletions

View File

@@ -5,14 +5,10 @@ class Ban < ActiveRecord::Base
attr_accessible :reason, :duration, :user_id
validate :user_is_inferior
def self.is_user_banned?(user)
def self.is_banned?(user)
exists?(["user_id = ? AND expires_at > ?", user.id, Time.now])
end
def self.is_ip_banned?(ip_addr)
exists?(["ip_addr = ? AND expires_at > ?", ip_addr, Time.now])
end
def user_is_inferior
if user
if user.is_admin?