Skip to main content

IAccountLockedHook

Hook interface for executing actions after account lockouts.

Overview

The IAccountLockedHook interface enables reactions to account lockout events triggered by failed login attempts exceeding configured thresholds.

The hook is non-blocking - errors are logged but do not affect the lockout operation.

Interface

interface IAccountLockedHook {
execute(metadata: AccountLockedMetadata): Promise<void>;
}

Metadata

AccountLockedMetadata

interface AccountLockedMetadata {
user: IUser;
reason: string;
lockType: 'temporary' | 'permanent';
lockDuration?: number;
lockedUntil?: Date;
ipAddress?: string;
failedAttempts?: number;
}
PropertyTypeDescription
userIUserUser whose account was locked
reasonstringReason for lockout
lockType'temporary' | 'permanent'Type of lock (temporary or permanent)
lockDurationnumberLock duration in seconds (temporary only)
lockedUntilDateWhen lock expires (temporary only)
ipAddressstringIP that triggered lockout
failedAttemptsnumberFailed attempts that triggered lockout

When Hook Fires

  • Account lockout threshold reached via rate limiting

Example

import { IAccountLockedHook, AccountLockedMetadata } from '@nauth-toolkit/core';

export class AccountLockedNotificationHook implements IAccountLockedHook {
async execute(metadata: AccountLockedMetadata): Promise<void> {
await this.emailService.sendAccountLockedEmail({
to: metadata.user.email,
lockType: metadata.lockType,
lockedUntil: metadata.lockedUntil,
ipAddress: metadata.ipAddress,
});
}
}