Guest User

Untitled

a guest
Mar 2nd, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. # This file is specifically setup for use with the merb-auth plugin.
  2. # This file should be used to setup and configure your authentication stack.
  3. # It is not required and may safely be deleted.
  4. #
  5. # To change the parameter names for the password or login field you may set either of these two options
  6. #
  7. Merb::Plugins.config[:"merb-auth"][:login_param] = :username
  8. # Merb::Plugins.config[:"merb-auth"][:password_param] = :my_password_field_name
  9.  
  10. begin
  11. # Sets the default class ofr authentication. This is primarily used for
  12. # Plugins and the default strategies
  13. Merb::Authentication.user_class = User
  14.  
  15.  
  16. # Mixin the salted user mixin
  17. require 'merb-auth-more/mixins/salted_user'
  18. Merb::Authentication.user_class.class_eval{ include Merb::Authentication::Mixins::SaltedUser }
  19.  
  20. # Setup the session serialization
  21. class Merb::Authentication
  22.  
  23. def fetch_user(session_user_id)
  24. Merb::Authentication.user_class.get(session_user_id)
  25. end
  26.  
  27. def store_user(user)
  28. user.nil? ? user : user.id
  29. end
  30. end
  31.  
  32. class MerbAuthSlicePassword::Sessions
  33. def redirect_after_login
  34. redirect_back_or "/", :ignore => [slice_url(:login), slice_url(:logout)]
  35. end
  36.  
  37. def redirect_after_logout
  38. redirect "/"
  39. end
  40. end
  41.  
  42. rescue
  43. Merb.logger.error <<-TEXT
  44.  
  45. You need to setup some kind of user class with merb-auth.
  46. Merb::Authentication.user_class = User
  47.  
  48. If you want to fully customize your authentication you should use merb-core directly.
  49.  
  50. See merb/merb-auth/setup.rb and strategies.rb to customize your setup
  51.  
  52. TEXT
  53. end
Add Comment
Please, Sign In to add comment