Removed methods that are unused and not needed
Removed the haspaid?, correct_case?, ign_is_not_skull and ign_is_not_mojang methods because they aren't used anymore, since we now have a connection between the server and the website to check if they have paid and that the skull is a skull. I also removed the account_exists? method because it makes problems when you setup the database since some users can be seen to not exist.
This commit is contained in:
@@ -21,8 +21,6 @@ class User < ActiveRecord::Base
|
|||||||
validates :email, uniqueness: {case_sensitive: false}, format: {with: /\A.+@(.+\..{2,}|\[[0-9a-f:.]+\])\z/i, message: "That doesn't look like an email address."}
|
validates :email, uniqueness: {case_sensitive: false}, format: {with: /\A.+@(.+\..{2,}|\[[0-9a-f:.]+\])\z/i, message: "That doesn't look like an email address."}
|
||||||
validates :ign, uniqueness: {case_sensitive: false}, format: {with: /\A[a-z\d_]+\z/i, message: "Username is invalid (a-z, 0-9, _)."}
|
validates :ign, uniqueness: {case_sensitive: false}, format: {with: /\A[a-z\d_]+\z/i, message: "Username is invalid (a-z, 0-9, _)."}
|
||||||
|
|
||||||
validate :account_exists?, :if => lambda {|user| user.ign_changed? }
|
|
||||||
|
|
||||||
has_many :blogposts
|
has_many :blogposts
|
||||||
has_many :comments
|
has_many :comments
|
||||||
|
|
||||||
@@ -113,45 +111,6 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# def haspaid?
|
|
||||||
# begin
|
|
||||||
# response = open("https://sessionserver.mojang.com/session/minecraft/profile/#{CGI.escape(self.uuid)}", read_timeout: 0.5)
|
|
||||||
# if response.status[0] == "200"
|
|
||||||
# session_profile = JSON.load(response.read)
|
|
||||||
# # unpaid accounts are called 'demo' accounts
|
|
||||||
# return session_profile["demo"] == true
|
|
||||||
# elsif response.status[0] == "204"
|
|
||||||
# # user doesn't exist
|
|
||||||
# return false
|
|
||||||
# else
|
|
||||||
# Rails.logger.error "---"
|
|
||||||
# Rails.logger.error "ERROR: unexpected response code while checking '#{self.uuid}' for premium account"
|
|
||||||
# Rails.logger.error "code: #{reponse.status}, body: '#{reponse.read}'"
|
|
||||||
# Rails.logger.error "---"
|
|
||||||
# end
|
|
||||||
# rescue => e
|
|
||||||
# Rails.logger.error "---"
|
|
||||||
# Rails.logger.error "ERROR: failed to check for premium account for '#{self.uuid}'. Minecraft servers down?"
|
|
||||||
# Rails.logger.error e.message
|
|
||||||
# Rails.logger.error "---"
|
|
||||||
# end
|
|
||||||
# # mojang servers have trouble
|
|
||||||
# return true
|
|
||||||
# end
|
|
||||||
|
|
||||||
# def correct_case?(ign)
|
|
||||||
# begin
|
|
||||||
# http = Net::HTTP.start("skins.minecraft.net")
|
|
||||||
# skin = http.get("/MinecraftSkins/#{CGI.escape(ign)}.png")
|
|
||||||
# http.finish
|
|
||||||
# rescue
|
|
||||||
# Rails.logger.error "---"
|
|
||||||
# Rails.logger.error "ERROR: failed to get skin status code for '#{ign}'. Skin servers down?"
|
|
||||||
# Rails.logger.error "---"
|
|
||||||
# end
|
|
||||||
# skin.code != "404"
|
|
||||||
# end
|
|
||||||
|
|
||||||
def get_profile
|
def get_profile
|
||||||
uri = URI.parse("https://api.mojang.com/profiles/minecraft")
|
uri = URI.parse("https://api.mojang.com/profiles/minecraft")
|
||||||
http = Net::HTTP.new(uri.host, uri.port)
|
http = Net::HTTP.new(uri.host, uri.port)
|
||||||
@@ -185,9 +144,6 @@ class User < ActiveRecord::Base
|
|||||||
[id, to_s.parameterize].join("-")
|
[id, to_s.parameterize].join("-")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_role
|
def set_role
|
||||||
@@ -204,13 +160,6 @@ class User < ActiveRecord::Base
|
|||||||
self.name ||= self.ign
|
self.name ||= self.ign
|
||||||
end
|
end
|
||||||
|
|
||||||
def account_exists?
|
|
||||||
profile = self.get_profile
|
|
||||||
if !profile || profile["demo"] == true
|
|
||||||
errors.add(:ign, "'#{self.ign}' is not a paid account!")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def strip_whitespaces
|
def strip_whitespaces
|
||||||
self.name.strip! if self.name
|
self.name.strip! if self.name
|
||||||
self.ign.strip! if self.ign
|
self.ign.strip! if self.ign
|
||||||
@@ -224,16 +173,4 @@ class User < ActiveRecord::Base
|
|||||||
def set_email_token
|
def set_email_token
|
||||||
self.email_token ||= SecureRandom.hex(16)
|
self.email_token ||= SecureRandom.hex(16)
|
||||||
end
|
end
|
||||||
|
|
||||||
# def ign_is_not_skull
|
|
||||||
# errors.add(:ign, "Good one...") if ["MHF_Blaze", "MHF_CaveSpider", "MHF_Chicken", "MHF_Cow", "MHF_Enderman", "MHF_Ghast", "MHF_Golem", "MHF_Herobrine", "MHF_LavaSlime", "MHF_MushroomCow", "MHF_Ocelot", "MHF_Pig", "MHF_PigZombie", "MHF_Sheep", "MHF_Slime", "MHF_Spider", "MHF_Squid", "MHF_Villager", "MHF_Cactus", "MHF_Cake", "MHF_Chest", "MHF_Melon", "MHF_OakLog", "MHF_Pumpkin", "MHF_TNT", "MHF_TNT2", "MHF_ArrowUp", "MHF_ArrowDown", "MHF_ArrowLeft", "MHF_ArrowRight", "MHF_Exclamation", "MHF_Question"].include?(self.ign)
|
|
||||||
# end
|
|
||||||
|
|
||||||
# def ign_is_not_mojang
|
|
||||||
# if self.ign.start_with?("mojang_secret_ign_")
|
|
||||||
# self.ign = self.ign[18..-1]
|
|
||||||
# else
|
|
||||||
# errors.add(:ign, "If that's really you, contact <a href='/users?role=staff'>us</a> in-game.") if ["mollstam", "carlmanneh", "MinecraftChick", "Notch", "jeb_", "xlson", "jonkagstrom", "KrisJelbring", "marc", "Marc_IRL", "MidnightEnforcer", "YoloSwag4Lyfe", "EvilSeph", "Grumm", "Dinnerbone", "geuder", "eldrone", "JahKob", "BomBoy", "MansOlson", "pgeuder", "91maan90", "vubui", "PoiPoiChen", "mamirm", "eldrone", "_tomcc"].include?(self.ign)
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
@@ -12,7 +12,6 @@ development:
|
|||||||
database: redstoner-web
|
database: redstoner-web
|
||||||
username: root
|
username: root
|
||||||
|
|
||||||
|
|
||||||
production:
|
production:
|
||||||
<<: *default
|
<<: *default
|
||||||
# please set ENV["DATABASE_URL"]
|
# please set ENV["DATABASE_URL"]
|
||||||
|
|||||||
Reference in New Issue
Block a user