Source

flask-auth / flaskext / auth / models / mongo.py

import datetime
from flaskext.auth import AuthUser

def now():
    return datetime.datetime.utcnow()

def get_user_class(db):
    class User(db.Document, AuthUser):
        """
        Implementation of User for SQLAlchemy.
        """
        username = db.StringField()
        password = db.StringField()
        salt = db.StringField()
        role = db.StringField(required=False)
        created = db.DateTimeField(default=now())
        modified = db.DateTimeField(default=now())

        def save(self):
            self.modified = now()
            super(User, self).save()
    return User