AsyncMoth

Here’s how AsyncMoth works

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

AsyncMoth blocks on __init__ when opening the MongoDB connection. All params are for creating said connection.

AsyncMoth is functionally equivalent to Moth, but with asynchronous support for use with Tornado/Motor.

auth_token(*args, **kwargs)

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(*args, **kwargs)

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(*args, **kwargs)

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

remove_token(*args, **kwargs)

Remove token from Moth

remove_user(*args, **kwargs)

Remove all user data from Moth

set_retval(*args, **kwargs)

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.