View as Markdown

Sell to a company#

An employee approves for their company, within the mandate it gave them.

Python only today.

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("POST", "/t/{tenant}/purchases", "purchases:make", cls="write-hard", level=2, mandate=True,
                    resource="tenant:{tenant}:purchase:new", amount_field="/total", summary="Buy for your company",
                    body={"total": "a decimal string, e.g. 300.00", "currency": "e.g. EUR"}))
templates["purchases:make"] = "Buy for {amount.max} {amount.currency}"
tenants["initech"] = {"name": "Initech", "org": os.environ["INITECH"], "routes": {}}  # the company's own site


@app.post("/t/<tenant>/purchases")
def purchase(tenant):
    # The person acts for the company, within the mandate it gave them.
    return {"bought": request.json["total"], "for": g.allowedby.acting_for["name"]}, 201

Run in 1 languages on this version. See the results

What the test proves#

  • an employee approves for her company, within the mandate it gave her; the app sees the company: 201
  • over her mandate (500 EUR), she cannot approve: refused
  • someone the company gave no mandate cannot approve: refused