<s> from app import db <EOL> import hashlib <EOL> ROLE_USER = <NUM_LIT:0> <EOL> ROLE_ADMIN = <NUM_LIT:1> <EOL> class User ( db . Document ) : <EOL> config_collection_name = '<STR_LIT>' <EOL> username = db . StringField ( ) <EOL> password = db . StringField ( ) <EOL> email = db . StringField ( ) <EOL> role = db . IntField ( default = ROLE_USER ) <EOL> firstname = db . StringField ( ) <EOL> lastname = db . StringField ( ) <EOL> about_me = db . StringField ( ) <EOL> created_at = db . CreatedField ( ) <EOL> updated_at = db . ModifiedField ( ) <EOL> def is_authenticated ( self ) : <EOL> return True <EOL> def is_active ( self ) : <EOL> return True <EOL> def is_anonymous ( self ) : <EOL> return False <EOL> def get_auth_token ( self ) : <EOL> return unicode ( hashlib . sha1 ( self . username + self . password ) . hexdigest ( ) ) <EOL> def get_id ( self ) : <EOL> return unicode ( self . mongo_id ) <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( self . username ) </s>
