Ejemplo n.º 1
0
 def load_user(user_id):
     try:
         user = UserModel.get(user_id, is_deleted=False)
     except UserModel.DoesNotExist:
         return None
     else:
         return user
Ejemplo n.º 2
0
def get_user_item_list(user_id):
    try:
        user = UserModel.get(id=user_id)
    except UserModel.DoesNotExist:
        raise NotFound(f"User {user_id} does not exist")

    return user.items
Ejemplo n.º 3
0
def login():
    validated_body = get_validated_body()

    try:
        user = UserModel.get(username=validated_body.get("username"),
                             is_deleted=False)
    except UserModel.DoesNotExist:
        raise NotFound

    if user.key.tobytes() != get_hash(password=validated_body.get("password"),
                                      salt=user.salt):
        raise Unauthorized

    login_user(user=user)

    return user
Ejemplo n.º 4
0
def get_user_details(id):
    return UserModel.get(id=id)
Ejemplo n.º 5
0
 def teardown_class(cls):
     user = UserModel.get(username="******")
     user.is_deleted = True
     user.save()
     print(user)