پرش به محتویات

تمدید

middlewareی که توکن access را سر راه تمدید می‌کند، و گام‌هایی که از آن‌ها ساخته شده.

از خود کد خوانده می‌شود، پس هیچ‌وقت از آن عقب نمی‌ماند. توضیح‌ها مال خود کد هستند، به انگلیسی.

RenewalMiddleware

RenewalMiddleware(get_response: Any)

Renews the access cookie in place, before any view reads it - sync or async.

renew

renew(request: HttpRequest) -> Outcome

What this request's session needs: a new access token, to be cleared, or nothing.

Nothing when there is no refresh cookie - a client signed in by header never had one, and clearing would delete cookies it never set - or when the access token is still good.

settle

settle(outcome: Outcome, response: HttpResponseBase) -> Renewed | Over | None

Put the outcome on response - unless the view already set the session itself.

Answers the outcome that reached the response, or None when nothing did.

announcement

announcement(outcome: Renewed | Over) -> tuple[Signal, dict[str, Any]]

The signal an outcome that reached the response is told by, and what it carries.

Renewed dataclass

Renewed(access: str, lifetime: timedelta, person: Any)

A new access token for person, and how long its cookie may last.

Over dataclass

Over(reason: Ended, person: Any = None)

The session is over: clear both cookies on the way out.