[**Documentation**](../../../README)

***

[Documentation](../../../README) / [@zerotal/auth](../README) / TWO\_FACTOR\_PENDING\_KEY

# Variable: TWO\_FACTOR\_PENDING\_KEY

> `const` **TWO\_FACTOR\_PENDING\_KEY**: `"two_factor_pending"` = `"two_factor_pending"`

Defined in: [auth/src/TwoFactorMiddleware.ts:20](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/auth/src/TwoFactorMiddleware.ts#L20)

Session key written by [Auth.login](Auth#login) when the user has a confirmed second factor.

While it is set the session is *half* authenticated: the password matched, the second
factor has not been presented. `PersistUserMiddleware` therefore leaves `ctx.user`
unset — so every route, API endpoint, admin page and Flow action treats the request
as a guest — and exposes the user only through [Auth.pendingTwoFactorUser](Auth#pendingtwofactoruser) so the
challenge page can render. [Auth.completeTwoFactor](Auth#completetwofactor) clears it.

This is what makes 2FA a *login* gate rather than a per-route one: enforcement does not
depend on a developer remembering to attach [TwoFactorMiddleware](../classes/TwoFactorMiddleware) to a route.
