mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-26 12:30:48 +00:00
Merge branch 'develop' into task/upgrade-ruby
This commit is contained in:
commit
96167b55e4
4 changed files with 91 additions and 53 deletions
|
@ -1,58 +1,57 @@
|
||||||
class PluginController < ApplicationController
|
class PluginController < ApplicationController
|
||||||
def user
|
def user
|
||||||
buffer = []
|
buffer = []
|
||||||
out = []
|
out = []
|
||||||
|
if ban = Ban.first(:conditions => ["expiry > UTC_TIMESTAMP() AND steamid = ? AND ban_type = ?", params[:id], Ban::TYPE_SERVER])
|
||||||
|
out << "#USER#"
|
||||||
|
out << "BANNED"
|
||||||
|
out << ban.expiry.utc.to_i
|
||||||
|
out << ban.reason
|
||||||
|
out << "\r\r\r\r\r\r\r"
|
||||||
|
elsif user = User.first(:conditions => {:steamid => params[:id]})
|
||||||
|
teamer = (user.team ? user.teamers.active.of_team(user.team).first : nil)
|
||||||
|
icon = 0
|
||||||
|
rank = "User"
|
||||||
|
if Group.find(Group::DONORS).users.exists?(user)
|
||||||
|
rank = "Donor"
|
||||||
|
icon = icon | 1
|
||||||
|
end
|
||||||
|
if Group.find(Group::CHAMPIONS).users.exists?(user)
|
||||||
|
icon = icon | 2
|
||||||
|
end
|
||||||
|
if user.ref?
|
||||||
|
rank = "Referee"
|
||||||
|
icon = icon | 4
|
||||||
|
end
|
||||||
|
if user.admin?
|
||||||
|
rank = "Admin"
|
||||||
|
icon = icon | 8
|
||||||
|
end
|
||||||
|
|
||||||
if ban = Ban.first(:conditions => ["expiry > UTC_TIMESTAMP() AND steamid = ? AND ban_type = ?", params[:id], Ban::TYPE_SERVER])
|
buffer << user.steamid
|
||||||
out << "#USER#"
|
buffer << user.username
|
||||||
out << "BANNED"
|
buffer << '0.0.0.0'
|
||||||
out << ban.expiry.utc.to_i
|
buffer << (user.team ? Verification.uncrap(user.team.to_s) : "No Team")
|
||||||
out << ban.reason
|
buffer << user.id
|
||||||
out << "\r\r\r\r\r\r\r"
|
buffer << user.team_id
|
||||||
elsif user = User.first(:conditions => {:steamid => params[:id]})
|
buffer << rank
|
||||||
teamer = (user.team ? user.teamers.active.of_team(user.team).first : nil)
|
buffer << (teamer ? teamer.ranks[teamer.rank] : "")
|
||||||
icon = 0
|
buffer << icon
|
||||||
rank = "User"
|
buffer << params[:ch] ? params[:ch] : ""
|
||||||
if Group.find(Group::DONORS).users.exists?(user)
|
buffer << (user.can_play? ? "1" : "0")
|
||||||
rank = "Donor"
|
|
||||||
icon = icon | 1
|
|
||||||
end
|
|
||||||
if Group.find(Group::CHAMPIONS).users.exists?(user)
|
|
||||||
icon = icon | 2
|
|
||||||
end
|
|
||||||
if user.ref?
|
|
||||||
rank = "Referee"
|
|
||||||
icon = icon | 4
|
|
||||||
end
|
|
||||||
if user.admin?
|
|
||||||
rank = "Admin"
|
|
||||||
icon = icon | 8
|
|
||||||
end
|
|
||||||
|
|
||||||
buffer << user.steamid
|
out << "#USER#"
|
||||||
buffer << user.username
|
out << Verification.verify(buffer.join)
|
||||||
buffer << user.lastip
|
out << buffer.join("\r")
|
||||||
buffer << (user.team ? Verification.uncrap(user.team.to_s) : "No Team")
|
else
|
||||||
buffer << user.id
|
out << "#FAIL#"
|
||||||
buffer << user.team_id
|
end
|
||||||
buffer << rank
|
|
||||||
buffer << (teamer ? teamer.ranks[teamer.rank] : "")
|
|
||||||
buffer << icon
|
|
||||||
buffer << params[:ch] ? params[:ch] : ""
|
|
||||||
buffer << (user.can_play? ? "1" : "0")
|
|
||||||
|
|
||||||
out << "#USER#"
|
render_out out
|
||||||
out << Verification.verify(buffer.join)
|
end
|
||||||
out << buffer.join("\r")
|
|
||||||
else
|
|
||||||
out << "#FAIL#"
|
|
||||||
end
|
|
||||||
|
|
||||||
render_out out
|
def render_out out
|
||||||
end
|
@text = out.join("\r")
|
||||||
|
render :layout => false
|
||||||
def render_out out
|
end
|
||||||
@text = out.join("\r")
|
|
||||||
render :layout => false
|
|
||||||
end
|
|
||||||
end
|
end
|
|
@ -63,5 +63,5 @@ Ensl::Application.configure do
|
||||||
config.active_support.deprecation = :notify
|
config.active_support.deprecation = :notify
|
||||||
|
|
||||||
# Custom Session Store config to allow gathers.staging.ensl.org
|
# Custom Session Store config to allow gathers.staging.ensl.org
|
||||||
config.session_store :cookie_store, key: '_ENSL_session_key', expire_after: 30.days.to_i, domain: "gathers.ensl.org"
|
# config.session_store :cookie_store, key: '_ENSL_session_key', expire_after: 30.days.to_i, domain: "gathers.ensl.org"
|
||||||
end
|
end
|
29
spec/controllers/plugin/plugin_controller_spec.rb
Normal file
29
spec/controllers/plugin/plugin_controller_spec.rb
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe PluginController do
|
||||||
|
render_views
|
||||||
|
|
||||||
|
describe '#user' do
|
||||||
|
before do
|
||||||
|
create :group, :donors
|
||||||
|
create :group, :champions
|
||||||
|
end
|
||||||
|
|
||||||
|
let!(:user) { create :user_with_team }
|
||||||
|
|
||||||
|
it 'returns user data' do
|
||||||
|
get :user, id: user.steamid
|
||||||
|
expect(response).to be_success
|
||||||
|
expect(response.body).to include(user.username)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'definitely does not return IP address' do
|
||||||
|
last_ip = '127.0.0.1'
|
||||||
|
user.lastip = last_ip
|
||||||
|
user.save!
|
||||||
|
get :user, id: user.steamid
|
||||||
|
expect(response).to be_success
|
||||||
|
expect(response).to_not include(last_ip)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -9,4 +9,14 @@ FactoryGirl.define do
|
||||||
name "Admins"
|
name "Admins"
|
||||||
id Group::ADMINS
|
id Group::ADMINS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
trait :champions do
|
||||||
|
name "Champions"
|
||||||
|
id Group::CHAMPIONS
|
||||||
|
end
|
||||||
|
|
||||||
|
trait :donors do
|
||||||
|
name "Donors"
|
||||||
|
id Group::DONORS
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue