recordLogin yourself after each successful sign-in.
Setup
createLastLoginModule is stateless and safe to call multiple times against the same database instance.
Recording a login
CallrecordLogin after any successful authentication. It validates its input (the userId must be non-empty and the method must be one of the values below) and returns a Result with the stored event:
maxHistoryPerUser (default: 10) are pruned automatically on every write.
Reading login data
Last login
null in data when no history exists for the user.
Full history
limit parameter overrides the module’s maxHistoryPerUser.
Supported methods
Result type
All methods returnResult<T>, either { success: true; data: T } or { success: false; error: TheAuthError }. Invalid input and database failures come back as success: false rather than thrown errors.
IP addresses are stored as-is. Normalise or hash them before passing if your privacy policy requires it.
Related
Authentication overview
All supported auth methods that generate login events.
Anomaly detection
What exists today for unusual behavior (theAuth has no login anomaly detector).
Trusted devices
Skip 2FA on devices you have marked as trusted.
Audit trail
Full agent-level action log for deeper activity analysis.