This method assumes that you have token authentication strategy enabled and will use the token for the user for cookie authentication
lib/devise/cookie_token_auth_strategy.rb
1234567891011121314151617181920212223
Warden::Strategies.add(:token_cookie_strategy)dodefvalid?token_from_cookieenddefauthenticate!iftoken_from_cookie.present?&&(user=User.find_for_token_authentication(:auth_token=>token_from_cookie)).present?delete_token_from_cookiesuccess!(user)elsefail!("Could not log in")endenddeftoken_from_cookiecookies[:authentication_token]enddefdelete_token_from_cookiecookies.delete(:authentication_token)endend