Skip to main content

AfterSessionCreatedFunction

AfterSessionCreatedFunction = (params) => Promise<void>

Called right after auth cookie with new session was issued, no matter which login method issued it (password login, OAuth, passkey, two-factor confirmation or any plugin which calls auth.setAuthCookie). Useful to persist sessions to revoke them later, or to log logins.

Thrown error is not caught, so it aborts response of the login request.

Parameters

ParameterTypeDescription
params{ adminforth: IAdminForth; expiresInSeconds: number; extra?: HttpExtra; pk: string | null; sessionId: string; username: string; }-
params.adminforthIAdminForthAdminforth instance.
params.expiresInSecondsnumberHow long the session (auth token) will live, in seconds.
params.extra?HttpExtraExtra HTTP information of request which issued the session, e.g. to get client IP or user agent. Not passed when session is issued outside of request handling.
params.pkstring | nullPrimary key of user the session was issued for.
params.sessionIdstringUnique id of created session. Same value is put into auth JWT and is available as AdminUser.sessionId on every request done with this session.
params.usernamestringUsername of user the session was issued for.

Returns

Promise<void>