Guest User

Untitled

a guest
Jun 20th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. class ApplicationController < ActionController::Base
  2. helper :all # include all helpers, all the time
  3. protect_from_forgery # See ActionController::RequestForgeryProtection for details
  4. require 'brazilian-rails'
  5. layout 'application'
  6. include AuthenticatedSystem
  7. before_filter :valida_permissao
  8.  
  9. private
  10. def valida_permissao
  11. if self.controller_name == 'sessions' and not self.action_name == 'index'
  12. true
  13. begin
  14. #=begin
  15. if logged_in?
  16. acao = Acao.find(:first, :conditions => ["controller_name = ? and action_name = ?",self.controller_name, self.action_name])
  17. if current_user.acoes.include? acao
  18. true
  19. else
  20. render :text => "Acesso negado a " + self.controller_name + ' acao ' + self.action_name + '. Você não tem acesso a esta ação.'
  21. end
  22. else
  23. render :text => "Acesso negado a " + self.controller_name + ' acao ' + self.action_name + '. Você não está logado'
  24. end
  25. #=end
  26. end
  27. end
  28. end
  29. end
Add Comment
Please, Sign In to add comment