Guest User

Untitled

a guest
Apr 26th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. LoggedExceptionsController.class_eval do
  2. # set the same session key as the app
  3. session :session_key => "profile_video_session"
  4.  
  5. # include any custom auth modules you need
  6. include AuthenticationSystem
  7.  
  8. before_filter :login_required
  9.  
  10. # optional, sets the application name for the rss feeds
  11. self.application_name = "Profile Video"
  12.  
  13. protected
  14. # only allow admins
  15. # this obviously depends on how your auth system works
  16. def authorized?
  17. current_user.is_a?(Admin)
  18. end
  19.  
  20. # assume app's login required doesn't use http basic
  21. def login_required_with_basic
  22. respond_to do |accepts|
  23. # alias_method_chain will alias the app's login_required to login_required_without_basic
  24. accepts.html { login_required_without_basic }
  25.  
  26. # access_denied_with_basic_auth is defined in LoggedExceptionsController
  27. # get_auth_data returns back the user/password pair
  28. accepts.rss do
  29. access_denied_with_basic_auth unless self.current_user = User.authenticate(*get_auth_data)
  30. end
  31. end
  32. end
  33.  
  34. alias_method_chain :login_required, :basic
  35. end
Add Comment
Please, Sign In to add comment