Guest User

Untitled

a guest
May 18th, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. ## The error page
  2. NameError in Admin#index
  3.  
  4. Showing admin/index.html.haml where line #1 raised:
  5.  
  6. uninitialized constant Authentication::USERS
  7.  
  8. Extracted source (around line #1):
  9.  
  10. 1: - if authenticated?
  11. 2: = render :controller => 'admin/categories'
  12. 3: = render :controller => 'admin/users'
  13.  
  14.  
  15. /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:275:in `load_missing_constant'
  16. /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:467:in `const_missing'
  17. lib/authentication.rb:11:in `authenticated?'
  18. app/views/admin/index.html.haml:1:in `_run_plugin_47app47views47admin47index46html46haml'
  19. /usr/bin/thin:19:in `load'
  20. /usr/bin/thin:19
  21.  
  22.  
  23. ## lib/authenticaton.rb
  24. module Authentication
  25.  
  26. def authenticate
  27. authenticated? || deny_authentication
  28. end
  29.  
  30. def authenticated?
  31. if !session[:name].nil? and !session[:password].nil?
  32. user = USERS[session[:name]]
  33. user['password'] == session[:password] unless user.nil?
  34. elsif USERS['skip']
  35. true
  36. else
  37. false
  38. end
  39. end
  40.  
  41. def deny_authentication
  42. flash[:notice] = "Vous n'êtes pas autorisé à accéder à cette page"
  43. redirect_to categories_path
  44. end
  45. end
  46.  
  47. ## config/users.yml
  48. production:
  49. test:
  50. password: test
  51.  
  52. test:
  53. skip: true
  54.  
  55. development:
  56. test:
  57. password: test
  58.  
  59.  
  60. ## config/initializers/users.rb
  61.  
  62. USERS = YAML.load_file("#{RAILS_ROOT}/config/users.yml")[RAILS_ENV]
Add Comment
Please, Sign In to add comment