Skip to main content

CMS Users & Authentication

Overview

This domain has three tables: user holds CMS accounts (scoped per organization), password_history stores hashed passwords with their expiry dates (the user table has no password column), and forgot_password stores the reset-link codes with their expiry.

Table user

ColumnTypeNullableDefaultDescription
idINTEGERNOT NULLnextval (serial)Primary key of the user
organization_idINTEGERNOT NULLOrganization the user belongs to (FK to organization.id)
emailTEXTNOT NULLLogin email address
avatarTEXTNULLURL/path of the profile picture
role_idINTEGERNOT NULL0User role (FK to system_role.id)
firstnameTEXTNOT NULLFirst name
lastnameTEXTNOT NULLLast name
typeUserType (enum)NOT NULLUser type: onemoby (platform team) or customer
statusCommonStatus (enum)NOT NULLAccount status (active, inactive, delete, etc.)
created_dateTIMESTAMPTZ(3)NOT NULLCURRENT_TIMESTAMPAccount creation timestamp
created_byINTEGERNOT NULL0User id of the creator
updated_dateTIMESTAMPTZ(3)NULLLast update timestamp (Prisma @updatedAt)
updated_byINTEGERNULL0User id of the last editor
deleted_dateTIMESTAMPTZ(3)NULLSoft-delete timestamp (NULL = not deleted)
verification_tokenVARCHAR(64)NULLToken for email verification / first password setup (present in the live DB but not yet tracked in Prisma)

Table password_history

ColumnTypeNullableDefaultDescription
idINTEGERNOT NULLnextval (serial)Sequence number
user_idINTEGERNOT NULL0User id — references user.id
passwordVARCHAR(255)NOT NULLPassword (stored hashed/encrypted)
created_dateTIMESTAMPTZ(3)NOT NULLCURRENT_TIMESTAMPCreation timestamp
expired_dateTIMESTAMPTZ(3)NOT NULLDate the password expires

Table forgot_password

ColumnTypeNullableDefaultDescription
idINTEGERNOT NULLnextval (serial)Sequence number
codeVARCHAR(50)NOT NULLCode used to validate that a password-reset URL is legitimate
user_idINTEGERNOT NULL0User id — references user.id
created_dateTIMESTAMPTZ(3)NOT NULLCURRENT_TIMESTAMPCreation timestamp
expired_dateTIMESTAMPTZ(3)NOT NULLDate the code expires
statusCommonStatus (enum)NOT NULLactiveStatus of the code (used/cancelled codes are no longer active)
deleted_dateTIMESTAMPTZ(3)NULLSoft-delete timestamp

Notes

  • Foreign keys: user.organization_id -> organization.id, user.role_id -> system_role.id, password_history.user_id -> user.id, forgot_password.user_id -> user.id
  • The user table has no password column. The active password is the most recent password_history row for that user, so this table serves as both current credential store and history (used to block password reuse) with expiry enforced via expired_date.
  • user has an index on deleted_date.
  • user is a PostgreSQL reserved word, so raw SQL must reference it as public."user".
  • There is no user_line_oa table. The similarly named object is line_user_line_oa_id_idx, an index on the line_oa_id column of the line_user table — not a separate table.