View as Markdown

Ask before deleting#

A change that is hard to undo: your app asks the person for that exact request, and the approval works once.

Level 2: A person whose identity is verified approves with a passkey.
Class write-hard: Hard to undo. The app creates the approval for that exact request, and it works once.
routes.append(route("DELETE", "/notes/{id}", "notes:delete", cls="write-hard", level=2, resource="note:{id}",
                    summary="Delete a note"))
templates["notes:delete"] = "Delete {scope}"


@app.delete("/notes/<note_id>")
def delete_note(note_id):
    # The person approved this exact request, and it works once.
    if not notes.delete(g.allowedby.human_id, note_id):
        return {"error": "no such note"}, 404
    return {"deleted": note_id}

What the test proves#

  • the approval to write does not delete: 401
  • the app asks for this exact request; the person verifies their identity (level 2) and approves: 200
  • the approval works once, and for no other note