Moth

Here’s how standard moth works.

class moth.Moth(database='moth', host='localhost', port=27017, user=None, pwd=None)

Moth requires the credentials to log in to MongoDB.

auth_token(email, token, ip=None)

Return True if email address and token match. If IP exists, also verify that. If expiration was set when create_token was called, verify that the token hasn’t expired. If for any reason the token is not valid, remove it.

create_token(email, ip=None, expire=None, token_size=64, retval=None)

Generate a token of a given length, tied to email address, and store it. Optionally store IP address, expiration (in days), and retval (see set_retval for additional information on this). Return the token

fetch_retval(email)

If retval exists, return it. If it doesn’t, return True.

remove_token(email, token)

Remove token from Moth.

remove_user(email)

Remove all user data from Moth.

set_retval(email, retval)

Store retval associated with the email address. When auth_token is called, if the authentication was successful, and a retval exists, it will be returned by the auth_token call. If retval does not exist, auth_token returns True.