def create(cls, username, password): return cls.collection.insert({ 'username': username, 'password': get_hash(password), 'rsa_fingerprint': None, 'public_key': None, 'last_auth': timestamp() })
def create(cls, sender, recipient, body, ip, browser): return cls.collection.insert({ 'sender': sender, 'recipient': recipient, 'body': body, 'ip': ip, 'browser': browser, 'timestamp': timestamp(), 'read': False })
def auth(cls, username, password): user = cls.collection.find_one({ '$or': [{'email': username}, {'username': username}] }) if user and verify_hash(password, user['password']): cls.collection.update( {'_id': user['_id']}, { '$set': {'last_auth': timestamp()} } ) return user
def auth(cls, username, password): user = cls.collection.find_one( {'$or': [{ 'email': username }, { 'username': username }]}) if user and verify_hash(password, user['password']): cls.collection.update({'_id': user['_id']}, {'$set': { 'last_auth': timestamp() }}) return user