Skip to main content

IUser

Package: @nauth-toolkit/core Type: Interface

Entity contract for user records implemented by database packages.

import { IUser } from '@nauth-toolkit/nestjs';

Properties

Identity

PropertyTypeRequiredDescription
idnumberYesDatabase auto-increment ID
substringYesPublic user identifier (UUID v4)
emailstringYesEmail address
usernamestring | nullYesUsername
phonestring | nullYesPhone number (E.164 format)
firstNamestring | nullYesFirst name
lastNamestring | nullYesLast name
metadataRecord<string, unknown> | nullYesCustom user metadata

Verification and status

PropertyTypeRequiredDescription
isEmailVerifiedbooleanYesWhether email is verified
isPhoneVerifiedbooleanYesWhether phone is verified
isActivebooleanYesWhether user account is active
mustChangePasswordbooleanYesWhether user must change password on next login
isLockedbooleanYesWhether account is locked
lockReasonstring | nullYesReason for account lock
lockedAtDate | nullYesWhen the account was locked
lockedUntilDate | nullYesWhen the lock expires (null = indefinite)

Login tracking

PropertyTypeRequiredDescription
failedLoginAttemptsnumberYesCount of consecutive failed login attempts
lastFailedLoginAtDate | nullYesTimestamp of last failed login
lastLoginAtDate | nullYesTimestamp of last successful login
lastLoginIpstring | nullYesIP address of last successful login

Social authentication

PropertyTypeRequiredDescription
hasSocialAuthbooleanYesWhether user has any linked social accounts
socialProvidersstring[] | nullYesList of linked social providers (e.g., ['google', 'apple'])

MFA

PropertyTypeRequiredDescription
mfaEnabledbooleanYesWhether MFA is enabled
mfaMethodsstring[] | nullYesConfigured MFA methods (e.g., ['totp', 'passkey'])
preferredMfaMethodstring | nullYesUser's preferred MFA method
mfaExemptbooleanNoWhether user is exempt from MFA
mfaExemptReasonstring | nullNoReason for MFA exemption
mfaExemptGrantedAtDate | nullNoWhen exemption was granted
mfaExemptGrantedBystring | nullNoAdmin who granted the exemption
backupCodesstring[] | nullYesHashed MFA backup codes

Password (internal)

PropertyTypeRequiredDescription
passwordHashstring | nullYesHashed password. Never expose directly.
passwordChangedAtDate | nullYesWhen password was last changed
passwordHistorystring[] | nullYesPrevious password hashes (for reuse prevention)
hasPasswordHashbooleanNoComputed field: whether user has a password set. Use this instead of checking passwordHash.
sessionAuthMethodstring | nullNoAuth method for the current session (e.g., password, google). Session-scoped, not an account capability.

Timestamps

PropertyTypeRequiredDescription
createdAtDateYesAccount creation timestamp
updatedAtDateYesLast update timestamp
deletedAtDate | nullYesSoft-delete timestamp (null if active)