Skip to main content
zerotal

Documentation


Documentation / @zerotal/auth / ConfirmPasswordMiddleware

Class: ConfirmPasswordMiddleware

Defined in: auth/src/ConfirmPasswordMiddleware.ts:35

Require a recent password confirmation before reaching sensitive routes.

If the user confirmed their password within timeoutSeconds, the request proceeds. Otherwise the originating URL is saved as intended_url and the user is redirected to redirectTo (or gets 423 Locked for JSON requests). After they confirm via Auth.confirmPassword(...), send them on with redirect().intended().

Example

Router.group({ middleware: [AuthMiddleware, ConfirmPasswordMiddleware] }, () => {
  Router.get("/settings/security", SecurityController, "show");
});

// Custom window / target:
ConfirmPasswordMiddleware.with({ redirectTo: "/verify", timeoutSeconds: 1800 })

Extends

Constructors

Constructor

new ConfirmPasswordMiddleware(): ConfirmPasswordMiddleware

Defined in: core/src/middleware/BaseMiddleware.ts:36

Returns

ConfirmPasswordMiddleware

Inherited from

BaseMiddleware.constructor

Properties

options

protected options: ConfirmPasswordOptions

Defined in: auth/src/ConfirmPasswordMiddleware.ts:36

Subclasses must declare this with their default option values. TypeScript enforces this at compile time — forgetting it is a type error.

Overrides

BaseMiddleware.options

Methods

handle()

handle(http, next): Promise<void | Response>

Defined in: auth/src/ConfirmPasswordMiddleware.ts:41

Parameters

http

HttpContext

next

NextFn

Returns

Promise<void | Response>

Overrides

BaseMiddleware.handle


with()

static with<T, Opts>(this, options): () => InstanceType<T>

Defined in: core/src/middleware/BaseMiddleware.ts:48

Returns a zero-arg subclass with the given options deep-merged on top of the subclass defaults, usable directly in app.use([...]).

Type Parameters

T

T extends (...args) => BaseMiddleware<any>

Opts

Opts = T extends (...args) => BaseMiddleware<U> ? U : object

Parameters

this

T

options

Partial<Opts>

Returns

() => InstanceType<T>

Inherited from

BaseMiddleware.with


afterResponse()?

optional afterResponse(ctx): Promise<void>

Defined in: core/src/middleware/BaseMiddleware.ts:70

Parameters

ctx

HttpContext

Returns

Promise<void>

Inherited from

BaseMiddleware.afterResponse


onError()?

optional onError(ctx, error): Promise<void>

Defined in: core/src/middleware/BaseMiddleware.ts:71

Parameters

ctx

HttpContext

error

Error

Returns

Promise<void>

Inherited from

BaseMiddleware.onError