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"})
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" })
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 })
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})
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 })
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", })
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})
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"})
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 })
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" })
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"})
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, })
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" })
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})