Guest User

Untitled

a guest
Feb 21st, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 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] = :email
  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. rescue
  33. Merb.logger.error <<-TEXT
  34.  
  35. You need to setup some kind of user class with merb-auth.
  36. Merb::Authentication.user_class = User
  37.  
  38. If you want to fully customize your authentication you should use merb-core directly.
  39.  
  40. See merb/merb-auth/setup.rb and strategies.rb to customize your setup
  41.  
  42. TEXT
  43. end
  44.  
  45. Merb::Authentication.after_authentication do |user, request, params|
  46. user.update_attributes(:logged_in_at => Time.now)
  47. user
  48. end
Add Comment
Please, Sign In to add comment