Auth & users

Accounts, sessions, and password security โ€” one enable call.

class=kw>import larz.auth as auth
auth.enable(app)             class=com># default User model + session auth; adds req.user

Register, log in, protect

app.auth.register("a@b.com", "password")    class=com># scrypt-hashed
app.auth.login(req, "a@b.com", "password")  class=com># sets the session
app.auth.logout(req)

@app.login_required
@app.get("/dashboard")
class=kw>def dash(req):
    class=kw>return "hi " + req.user.email

Email verification & password reset

token = app.auth.make_verify_token(user)      class=com># email this link
app.auth.confirm_verify_token(token)

token = app.auth.make_reset_token(user)       class=com># time-limited
app.auth.reset_password(token, "new-password")

Tokens are signed and expire; nothing is stored server-side.

Auth integrates with money: a logged-in user's entitlements follow their account (req.subject = user:<id>), not their browser โ€” so they keep Pro across devices. Next: API keys & roles.