Skip to main content

AfterLoginFailedFunction

AfterLoginFailedFunction = (params) => Promise<void>

Called after password login attempt failed, right before AdminForth answers with 401. Not called for attempts blocked by auth.rateLimit. Useful to log failed attempts or to notify user about bruteforce of their account.

Can't change response of the login request: thrown error is logged and login still answers with 401.

Parameters​

ParameterTypeDescription
params{ adminforth: IAdminForth; extra: HttpExtra; pk: string | null; reason: LoginFailureReason; username: string; }-
params.adminforthIAdminForthAdminforth instance.
params.extraHttpExtraExtra HTTP information of login request.
params.pkstring | nullPrimary key of user with such username. Is null when reason is rejected or user_not_found.
params.reasonLoginFailureReasonWhy login attempt failed.
params.usernamestringUsername which user tried to login with, normalized in same way as it is stored in database.

Returns​

Promise<void>