Esempio n. 1
0
def get_user(userid=''):
    """
    GET /user
    Gets a user.

    The user's private properties are not returned unless you pass a correct collection key.
    """

    key = request.args.get("key")
    try:
        user = UserFactory.get(userid, mydao, key)
    except KeyError:
        abort(404, "User doesn't exist.")
    except NotAuthenticatedError:
        abort(403, "You've got the wrong password.")

    resp = make_response(json.dumps(user, indent=4), 200)
    resp.mimetype = "application/json"
    return resp
Esempio n. 2
0
def update_user(userid=""):
    """
    PUT /collection
    creates new collection
    """

    new_stuff = request.json
    try:
        key = new_stuff["key"]
    except KeyError:
        abort(400, "the submitted user object is missing required properties.")
    try:
        res = UserFactory.put(new_stuff, key, mydao)
    except NotAuthenticatedError:
        abort(403, "You've got the wrong password.")
    except AttributeError:
        abort(400, "the submitted user object is missing required properties.")

    resp = make_response(json.dumps(res, indent=4), 200)
    resp.mimetype = "application/json"
    return resp