Created
December 4, 2013 20:15
-
-
Save soey/7794712 to your computer and use it in GitHub Desktop.
monkey patch devise token authenticable to survive baked in cookies..
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# monkey patch devise token authenticable to have tokens surviving in cookies | |
require 'securerandom' | |
module Devise | |
module Models | |
module TokenAuthenticatable | |
module ClassMethods | |
# Generate a token checking if one does not already exist in the database. | |
def authentication_token | |
loop do | |
token = SecureRandom.hex(32) | |
break token unless to_adapter.find_first({ :authentication_token => token }) | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment