   end
 
   @doc """
-  Returns the given token with the given context.
+  Returns the token struct for the given token value and context.
   """
   def token_and_context_query(token, context) do
     from <%= inspect schema.module %>Token, where: [token: ^token, context: ^context]

  end

  @doc """
  Builds a token with a hashed counter part.

  The non-hashed token is sent to the <%= schema.singular %> email while the
  hashed part is stored in the database, to avoid reconstruction.
  The token is valid for a week as long as <%= schema.singular %>s don't change
  their email.
  """
  def build_email_token(<%= schema.singular %>, context) do
    build_hashed_token(<%= schema.singular %>, context, <%= schema.singular %>.email)

  @doc """
  Checks if the token is valid and returns its underlying lookup query.

  The query returns the <%= schema.singular %> found by the token, if any.

  The given token is valid if it matches its hashed counterpart in the
  database and the user email has not changed. This function also checks
  if the token is being used within a certain period, depending on the
  context. The default contexts supported by this function are either
  "confirm", for account confirmation emails, and "reset_password",
  for resetting the password. For verifying requests to change the email,
  see `verify_change_email_token_query/2`.
  """
  def verify_email_token_query(token, context) do
    case Base.url_decode64(token, padding: false) do
