コード例 #1
0
def set_password(password_id):
    data = request.get_json()
    if not data:
        abort(415)

    safe_session = get_safe_session()
    if not safe_session:
        return jsonify(__auth_error)

    try:
        password = Password.get(Password.id == password_id)
    except Password.DoesNotExist:
        abort(404)
        return

    if password.owner.id != safe_session.user.id:
        abort(403)

    with DB_CONNECTION.atomic():
        if "passwordName" in data and data["passwordName"]:
            password.name = data["passwordName"]
        if "passwordValue" in data and data["passwordValue"]:
            password.value = data["passwordValue"]
        password.save()

    return jsonify({"status": "ok"})
コード例 #2
0
ファイル: rest.py プロジェクト: zebraxxl/micro-pass
def set_password(password_id):
    data = request.get_json()
    if not data:
        abort(415)

    safe_session = get_safe_session()
    if not safe_session:
        return jsonify(__auth_error)

    try:
        password = Password.get(Password.id == password_id)
    except Password.DoesNotExist:
        abort(404)
        return

    if password.owner.id != safe_session.user.id:
        abort(403)

    with DB_CONNECTION.atomic():
        if "passwordName" in data and data["passwordName"]:
            password.name = data["passwordName"]
        if "passwordValue" in data and data["passwordValue"]:
            password.value = data["passwordValue"]
        password.save()

    return jsonify({
        "status": "ok"
    })
コード例 #3
0
ファイル: rest.py プロジェクト: zebraxxl/micro-pass
def get_session_key():
    safe_session = get_safe_session()
    if not safe_session:
        return jsonify(__auth_error)
    return jsonify({
        "status": "ok",
        "sessionKey": safe_session.session_key
    })
コード例 #4
0
def get_private_data():
    safe_session = get_safe_session()
    if not safe_session:
        return jsonify(__auth_error)

    user = User.get(User.id == safe_session.user_id)

    return jsonify({"status": "ok", "privateData": user.private_data})
コード例 #5
0
ファイル: rest.py プロジェクト: zebraxxl/micro-pass
def get_private_data():
    safe_session = get_safe_session()
    if not safe_session:
        return jsonify(__auth_error)

    user = User.get(User.id == safe_session.user_id)

    return jsonify({
        "status": "ok",
        "privateData": user.private_data
    })
コード例 #6
0
ファイル: rest.py プロジェクト: zebraxxl/micro-pass
def logout():
    safe_session = get_safe_session()
    if not safe_session:
        return jsonify(__auth_error)

    with DB_CONNECTION.atomic():
        safe_session.session_expire = datetime.utcnow() - SESSION_ALIVE_TIME
        safe_session.save()

    return jsonify({
        "status": "ok",
    })
コード例 #7
0
def logout():
    safe_session = get_safe_session()
    if not safe_session:
        return jsonify(__auth_error)

    with DB_CONNECTION.atomic():
        safe_session.session_expire = datetime.utcnow() - SESSION_ALIVE_TIME
        safe_session.save()

    return jsonify({
        "status": "ok",
    })
コード例 #8
0
def create_password():
    data = request.get_json()
    if not data or "passwordName" not in data or "passwordValue" not in data:
        abort(415)

    safe_session = get_safe_session()
    if not safe_session:
        return jsonify(__auth_error)

    password = Password.create(owner=safe_session.user,
                               name=data["passwordName"],
                               value=data["passwordValue"])

    return jsonify({"status": "ok", "passwordId": password.id})
コード例 #9
0
def set_private_data():
    safe_session = get_safe_session()
    if not safe_session:
        return jsonify(__auth_error)

    data = request.data
    if not data:
        abort(415)

    with DB_CONNECTION.atomic():
        safe_session.user.private_data = request.data
        safe_session.user.save()

    return jsonify({"status": "ok"})
コード例 #10
0
ファイル: rest.py プロジェクト: zebraxxl/micro-pass
def create_password():
    data = request.get_json()
    if not data or "passwordName" not in data or "passwordValue" not in data:
        abort(415)

    safe_session = get_safe_session()
    if not safe_session:
        return jsonify(__auth_error)

    password = Password.create(owner=safe_session.user, name=data["passwordName"], value=data["passwordValue"])

    return jsonify({
        "status": "ok",
        "passwordId": password.id
    })
コード例 #11
0
ファイル: rest.py プロジェクト: zebraxxl/micro-pass
def set_private_data():
    safe_session = get_safe_session()
    if not safe_session:
        return jsonify(__auth_error)

    data = request.data
    if not data:
        abort(415)

    with DB_CONNECTION.atomic():
        safe_session.user.private_data = request.data
        safe_session.user.save()

    return jsonify({
        "status": "ok"
    })
コード例 #12
0
def delete_password(password_id):
    safe_session = get_safe_session()
    if not safe_session:
        return jsonify(__auth_error)

    try:
        password = Password.get(Password.id == password_id)
    except Password.DoesNotExist:
        abort(404)
        return

    if password.owner.id != safe_session.user.id:
        abort(403)

    with DB_CONNECTION.atomic():
        password.delete_instance()

    return jsonify({"status": "ok"})
コード例 #13
0
ファイル: rest.py プロジェクト: zebraxxl/micro-pass
def get_password(password_id):
    safe_session = get_safe_session()
    if not safe_session:
        return jsonify(__auth_error)

    try:
        password = Password.get(Password.id == password_id)
    except Password.DoesNotExist:
        abort(404)
        return

    if password.owner.id != safe_session.user.id:
        abort(403)

    return jsonify({
        "status": "ok",
        "passwordName": password.name,
        "passwordValue": password.value,
    })
コード例 #14
0
def get_password(password_id):
    safe_session = get_safe_session()
    if not safe_session:
        return jsonify(__auth_error)

    try:
        password = Password.get(Password.id == password_id)
    except Password.DoesNotExist:
        abort(404)
        return

    if password.owner.id != safe_session.user.id:
        abort(403)

    return jsonify({
        "status": "ok",
        "passwordName": password.name,
        "passwordValue": password.value,
    })
コード例 #15
0
ファイル: rest.py プロジェクト: zebraxxl/micro-pass
def delete_password(password_id):
    safe_session = get_safe_session()
    if not safe_session:
        return jsonify(__auth_error)

    try:
        password = Password.get(Password.id == password_id)
    except Password.DoesNotExist:
        abort(404)
        return

    if password.owner.id != safe_session.user.id:
        abort(403)

    with DB_CONNECTION.atomic():
        password.delete_instance()

    return jsonify({
        "status": "ok"
    })
コード例 #16
0
def get_session_key():
    safe_session = get_safe_session()
    if not safe_session:
        return jsonify(__auth_error)
    return jsonify({"status": "ok", "sessionKey": safe_session.session_key})