✅ Authentication validators
Authentication routes compose these shared validators to authenticate requests and restrict access to administrators, the affected identity, or either of those principals.
Inventory
Details
isAuthenticated()
Implementation
Signature: isAuthenticated(): Validator. authService supplies Bearer authentication by default and cookie authentication when authMode is 'cookie'; register cookie-parser before cookie-mode routes.
Consumers: logoutRoute, deleteRefreshTokensRoute, generateOnetimeTokenRoute, restoreOnetimeTokenRoute, invalidateOnetimeTokenRoute, sendVerificationEmailRoute, changeEmailRoute, changePasswordRoute, deactivateRoute, and activateRoute.
checkIdentityType(['admin'])
Implementation
Signature: checkIdentityType(['admin']): Validator. Factory invocation authenticates the request, requires configured identity type IDs, loads the token identity, and succeeds only when its type matches the configured administrator ID. Missing configuration is 500, token failure is 401, and a missing identity or disallowed type is 403.
Consumers: Direct on generateOnetimeTokenRoute, restoreOnetimeTokenRoute, invalidateOnetimeTokenRoute, and activateRoute, and the administrator branch of some(...) on deleteRefreshTokensRoute, sendVerificationEmailRoute, changeEmailRoute, changePasswordRoute, and deactivateRoute.
isSelf(path)
Implementation
Signature: isSelf<T extends string>(identityIdPathInPayload: [T, ...T[]]): Validator. Compares the authenticated token identity with the configured target path: requestParams.identityId for refresh-token deletion, verification, email/password changes; requestBody.identityId for deactivation.
Consumers: the some(...) branches in deleteRefreshTokensRoute, sendVerificationEmailRoute, changeEmailRoute, changePasswordRoute, and deactivateRoute.
some(...validators)
Implementation
Signature: some(...args: Validator[]): Validator. Combines administrator and self checks where source permits either principal.
Consumers: deleteRefreshTokensRoute, sendVerificationEmailRoute, changeEmailRoute, changePasswordRoute, and deactivateRoute.