mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-02-06 00:11:10 +00:00
Update bans to use strong parameters
This commit is contained in:
parent
d4e8a7a7ad
commit
14943fc040
2 changed files with 10 additions and 3 deletions
|
@ -18,7 +18,7 @@ class BansController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@ban = Ban.new(params[:ban])
|
@ban = Ban.new(ban_create_params)
|
||||||
raise AccessError unless @ban.can_create? cuser
|
raise AccessError unless @ban.can_create? cuser
|
||||||
@ban.creator = cuser
|
@ban.creator = cuser
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class BansController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
raise AccessError unless @ban.can_update? cuser
|
raise AccessError unless @ban.can_update? cuser
|
||||||
if @ban.update_attributes(params[:ban])
|
if @ban.update_attributes(ban_update_params)
|
||||||
flash[:notice] = t(:bans_update)
|
flash[:notice] = t(:bans_update)
|
||||||
redirect_to(@ban)
|
redirect_to(@ban)
|
||||||
else
|
else
|
||||||
|
@ -51,4 +51,12 @@ class BansController < ApplicationController
|
||||||
def get_ban
|
def get_ban
|
||||||
@ban = Ban.find(params[:id])
|
@ban = Ban.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ban_create_params
|
||||||
|
params.require(:ban).pemit(:steamid, :addr, :reason, :len, :user_name, :creator, :ban_type, :ip, :server, :len, :expiry)
|
||||||
|
end
|
||||||
|
|
||||||
|
def ban_update_params
|
||||||
|
params.require(:ban).permit(:steamid, :addr, :reason, :len, :user_name, :ban_type, :ip, :server, :len, :expiry)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,7 +26,6 @@ class Ban < ActiveRecord::Base
|
||||||
TYPE_GATHER = 5
|
TYPE_GATHER = 5
|
||||||
VENT_BANS = "tmp/bans.txt"
|
VENT_BANS = "tmp/bans.txt"
|
||||||
|
|
||||||
attr_protected :id, :created_at, :updated_at
|
|
||||||
attr_accessor :len, :user_name
|
attr_accessor :len, :user_name
|
||||||
|
|
||||||
scope :ordered, order: "created_at DESC"
|
scope :ordered, order: "created_at DESC"
|
||||||
|
|
Loading…
Reference in a new issue