Esempio n. 1
0
def add_user(request):
    username = request.json_body['username']
    password = request.json_body['password']
    db = request.db
    new_user = db['users'].insert({'username': username,
                                   'password': password_manager.encode(password),
                                   'groups': ['buyer'],
                                   'token': remember(request, username)})
    return {}
Esempio n. 2
0
def add_client(request):
    mobile = request.json_body['client']['mobile']
    name = request.json_body['client']['name']
    db = request.db
    new_user = db['users'].insert({'username': mobile,
                                   'name': name,
                                   'orders': [],
                                   'password': password_manager.encode('keptrans'),
                                   'groups': ['buyer'],
                                   'staff': False,
                                   'token': remember(request, mobile)})
    return {'client': {'mobile': mobile, 'name': name, 'id': str(new_user)}}