module Devise::Models::TokenAuthenticatable::ClassMethods

def authenticate_with_token(attributes)

Authenticate a user based on authentication token.
def authenticate_with_token(attributes)
  token = attributes[self.token_authentication_key]
  resource = self.find_for_token_authentication(token)
  resource if resource.try(:valid_authentication_token?, token)
end