Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aliang/1022440 to your computer and use it in GitHub Desktop.
Save aliang/1022440 to your computer and use it in GitHub Desktop.
Monkeypatch Devise to support saving sessions via HTTP auth (e.g. via bookmarklets or browser addons)
# config/initializers/devise_http_rememberable.rb
# Monkeypatch Devise so HTTP authentication sets remember_user_token cookie
# ABR: Always Be Remembering
module Devise
module Strategies
class Authenticatable < Base
def remember_me?
# Devise's implementation of this is:
# valid_params? && Devise::TRUE_VALUES.include?(params_auth_hash[:remember_me])
# which only works for param authentication, not http authentication
true
end
end
end
end
@aliang
Copy link
Author

aliang commented Jul 14, 2011

You can probably subclass the existing strategy, actually, which would be cleaner I guess?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment