mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 16:19:52 +01:00
moved privileged? method from answer_controller to application_controller
This commit is contained in:
parent
3994bdeb02
commit
6fb97c9ecc
2 changed files with 11 additions and 12 deletions
|
@ -8,6 +8,8 @@ class Ajax::AnswerController < ApplicationController
|
|||
|
||||
answer = Answer.find(params[:answer])
|
||||
|
||||
puts ">>>>>>>>>>>>", privileged?.inspect
|
||||
|
||||
unless answer.user == current_user || privileged?
|
||||
@status = :nopriv
|
||||
@message = "check yuor privlegs"
|
||||
|
@ -23,15 +25,4 @@ class Ajax::AnswerController < ApplicationController
|
|||
@message = "Successfully deleted answer."
|
||||
@success = true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# TODO:
|
||||
def privileged?
|
||||
if current_user && current_user.admin?
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,15 @@ class ApplicationController < ActionController::Base
|
|||
protect_from_forgery with: :exception
|
||||
|
||||
before_filter :configure_permitted_parameters, if: :devise_controller?
|
||||
|
||||
|
||||
def privileged?
|
||||
if current_user && current_user.admin?
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def configure_permitted_parameters
|
||||
|
|
Loading…
Reference in a new issue