From ec8d0095f32356c5f1ba2eef55903f3aedc66828 Mon Sep 17 00:00:00 2001 From: Jonas Folvik Date: Mon, 18 Jan 2016 20:28:03 +0100 Subject: 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. --- app/models/user.rb | 63 ----------------------------------------------------- config/database.yml | 1 - 2 files changed, 64 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 83d668a..7bb67e8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 :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 :comments @@ -113,45 +111,6 @@ class User < ActiveRecord::Base 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 uri = URI.parse("https://api.mojang.com/profiles/minecraft") http = Net::HTTP.new(uri.host, uri.port) @@ -185,9 +144,6 @@ class User < ActiveRecord::Base [id, to_s.parameterize].join("-") end - - - private def set_role @@ -204,13 +160,6 @@ class User < ActiveRecord::Base self.name ||= self.ign 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 self.name.strip! if self.name self.ign.strip! if self.ign @@ -224,16 +173,4 @@ class User < ActiveRecord::Base def set_email_token self.email_token ||= SecureRandom.hex(16) 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 us 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 \ No newline at end of file diff --git a/config/database.yml b/config/database.yml index efae840..f421bef 100644 --- a/config/database.yml +++ b/config/database.yml @@ -12,7 +12,6 @@ development: database: redstoner-web username: root - production: <<: *default # please set ENV["DATABASE_URL"] -- cgit v1.2.3