Skip to main content

BeforeLoginAttemptFunction

BeforeLoginAttemptFunction = (params) => Promise<{ error?: string; ok: boolean; }>

Allows to reject login attempt before AdminForth checks credentials in the database. Called on every call of login endpoint, even if username does not exist or password is wrong, so it is a right place for captcha and other anti-bruteforce checks: user gets the same response regardless of whether credentials were correct.

Parameters

ParameterTypeDescription
params{ adminforth: IAdminForth; extra: HttpExtra; username: string; }-
params.adminforthIAdminForthAdminforth instance.
params.extraHttpExtraExtra HTTP information of login request. Use extra.response to set custom status or headers.
params.usernamestringUsername which user tries to login with, normalized in same way as it is stored in database.

Returns

Promise<{ error?: string; ok: boolean; }>