summaryrefslogtreecommitdiff
path: root/app/controllers/alerts_controller.rb
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-03-05 22:53:41 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-03-05 22:53:41 -0500
commit526bff770017a1f6a66e45b5b6e61840711078b8 (patch)
tree6efe701f65affd361a4b173938f824a9621a1786 /app/controllers/alerts_controller.rb
parentc6471297f0a871ba1062f1285790d39e5471b966 (diff)
add access control to the controllers for alerts, servers, and tournaments
Diffstat (limited to 'app/controllers/alerts_controller.rb')
-rw-r--r--app/controllers/alerts_controller.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/controllers/alerts_controller.rb b/app/controllers/alerts_controller.rb
index 873e9b7..9e37ec9 100644
--- a/app/controllers/alerts_controller.rb
+++ b/app/controllers/alerts_controller.rb
@@ -1,5 +1,6 @@
class AlertsController < ApplicationController
before_action :set_alert, only: [:show, :edit, :update, :destroy]
+ before_action :check_perms, only: [:new, :create, :edit, :update, :destroy]
# GET /alerts
# GET /alerts.json
@@ -67,6 +68,15 @@ class AlertsController < ApplicationController
@alert = Alert.find(params[:id])
end
+ def check_perms
+ unless (signed_in? and (current_user.in_group(:admin) or current_user.in_group(:host)))
+ respond_to do |format|
+ format.html { render action: 'permission_denied', status: :forbidden }
+ format.json { render json: "Permission denied", status: :forbidden }
+ end
+ end
+ end
+
# Never trust parameters from the scary internet, only allow the white list through.
def alert_params
params.require(:alert).permit(:author_id, :message)