Skip to content

PRD: Employee management

ModuleUser Management (CORE-01)PRD IDPRD-EMP-001
StatusIn-progressOwnerUser Management squad
Date2026-05-25Versionv0.1
Packages@nx/identity · @nx/commerce (Organizer/Merchant ownership)URDEMP

TL;DR

Lets a business owner create staff accounts and bind them to specific merchants within their organization, so employees sign in with their own credentials and see only the merchants they are assigned to. Owners can reassign or deactivate staff at any time, and the system sends set/reset-password mail so employees activate their own login. The result: a controlled, ownership-validated employee lifecycle that reuses the existing role/scoping machinery - no shared owner logins, no unscoped staff access.

1. Context & Problem

Owners onboard a business and then need staff who can operate it. Today employee management is thin - there is no first-class flow for an owner to create staff accounts, bind them to specific merchants in their organization, and reassign or revoke that access. Without it, owners share a single login or hand out broad access, which breaks per-merchant scoping and leaves no clean way to off-board someone.

Employee management grounds the staff-account half of the URD's purpose - "how business owners manage employees within their organizations" - and reuses the existing role/scoping machinery so an employee only ever sees the merchants they are assigned to.

2. Goals & Non-Goals

Goals

  • Owner-driven employee account creation with the Employee role, linked to an organization and one or more merchants.
  • Ownership validation: the acting owner must own the organization and every listed merchant before any grant is written.
  • Scope-filtered find/count of employees and their role-merchant mappings, with system roles excluded from the mapping.
  • Update: replace merchant assignments, add/update a username, and revoke or grant login access.
  • Deactivate / remove an employee account via soft-delete.
  • Set-password and reset-password mail flow, with mail configuration read from the database.

Non-Goals

  • Custom role creation / dynamic permission management → Permissions.
  • A user invitation system (email/phone invites) - excluded by the URD scope.
  • Multi-organization access for a single user.
  • Audit / login history for employee actions.

3. Success Metrics

MetricTarget / signal
Scoping correctnessEmployees can read/operate only their assigned merchants; zero cross-merchant leakage
Ownership safety100% of create/update calls reject when the owner does not own the org or a listed merchant
Self-activationSet-password mail delivered on creation; employees activate their own login
Off-boardingDeactivated/removed employees can no longer sign in

4. Personas & Use Cases

PersonaGoal in this feature
OwnerCreate staff, scope them to merchants, reassign or off-board them
EmployeeSign in with own credentials and operate only assigned merchants

Core scenarios: an owner creates an employee with a merchant list (validated against ownership) → set-password mail goes out → the employee signs in scoped to those merchants → the owner later replaces the merchant assignments or deactivates the account.

5. User Stories

  • As an owner, I want to create an employee account scoped to one or more of my merchants, so staff can operate only the stores I assign.
  • As an owner, I want the system to reject any merchant or organization I do not own, so I cannot accidentally grant access outside my business.
  • As an owner, I want to replace an employee's merchant assignments, so I can move staff between stores in one update.
  • As an owner, I want to add a username and (re)send set/reset-password mail, so an employee can activate or recover their own login.
  • As an owner, I want to deactivate or remove an employee, so off-boarded staff lose access while their data is preserved.
  • As an employee, I want to sign in with my own credentials and see only my merchants, so my view matches my responsibilities.

6. Functional Requirements

#RequirementURD ref
FR-1Owner creates an employee account with the Employee roleURD-EMP-001
FR-2Employee is linked to an organization and one or more merchantsURD-EMP-002
FR-3Employee can access only the merchants they are assigned toURD-EMP-003
FR-4Employee can sign in with their own credentialsURD-EMP-004
FR-5Data queries for an employee are filtered by their merchant assignments; system roles are excluded from the role-merchant mappingURD-EMP-005
FR-6Owner can update merchant assignments (replaces all previous assignments), add/update a username, and revoke/grant login accessURD-EMP-006
FR-7Owner can deactivate or remove an employee account (soft-delete)URD-EMP-007
FR-8System validates that the owner owns the organization and every listed merchant before grantingURD-EMP-008
FR-9Set-password mail is sent on creation (and when a username is added on update); reset-password mail is sent on request, with mail configuration read from the databaseURD-EMP-001 · URD-EMP-004

Full requirement text and acceptance criteria live in the User Management URD. This PRD references them rather than restating them.

7. Non-Functional Requirements

AreaRequirement
Data integrityAccount, Employee role, and organization/merchant grants are created together - partial creation is rejected
Tenancy & authzEvery operation is ownership-validated against the acting owner's organization and merchants; an owner cannot manage a role at or above their own priority
ScopingFind/count is filtered to the caller's scope; system roles are excluded from the role-merchant mapping
Soft-deleteEmployee accounts are never physically deleted; removal is a soft-delete
SecurityPasswords are hashed and never returned; the session token is removed from the reset-password response
i18nUser-facing labels/statuses are bilingual ({ en, vi })

8. UX & Flows

Key flows live in @nx/identity (employee create/find/count/update/delete and the set/reset-password mail path). The owner-facing UI for staff management lives in the client app.

9. Data & Domain

EntityRole
UserThe employee's account - identity, status, soft-delete
CredentialHashed password; set/reset via the password-mail flow
IdentifierUsername/email/phone login values added on create/update
Role (Employee)Classifies the account and drives scoping; system roles excluded from the mapping
Role-merchant grantBinds the employee to an organization and its assigned merchants
Organizer / Merchant (commerce)Ownership source - consumed to validate the owner owns the org and merchants

Conceptual only - full schema in the developer domain model.

10. Dependencies & Assumptions

Depends on

  • Roles & Scoping (URD-ROLE) - the Employee role and the scope-filtering machinery employee lifecycle reuses.
  • Authentication (URD-AUTH) - employees sign in with their own credentials.
  • Commerce (@nx/commerce) - Organizer / Merchant ownership is the source of truth for validation.
  • Mail configuration stored in the database for the set/reset-password path.

Assumptions

  • The acting owner already owns an organization with at least one merchant.
  • A mail configuration row exists so set/reset-password mail can be sent.

11. Risks & Open Questions

Risk / questionMitigation / status
Granting access to a merchant the owner does not ownOwnership validated against OrganizerRepository / MerchantRepository before any grant
System roles leaking into the role-merchant mappingSystem roles filtered out when counting/listing the mapping
Session token exposure on password resetSession token removed from the reset-password response
No audit/login history for employee actionsOut of scope for this increment; revisit when audit is prioritized
Single-organization assumptionMulti-organization access for one user is an explicit non-goal

12. Release Plan & Launch Criteria

AspectPlan
PhaseP2 of the EMP feature - see URD feature catalog
RolloutAll merchants; no feature flag
MigrationMail-configuration seed added; no destructive data migration
Launch criteriaCreate→scope→sign-in verified end-to-end; ownership validation rejects non-owned org/merchants; set/reset-password mail delivered; soft-deleted employees cannot sign in
MonitoringEmployee create/update error rate, ownership-rejection rate, set/reset-password mail delivery

13. FAQ

Can an employee belong to more than one organization? No - multi-organization access for a single user is out of scope; an employee is linked to one organization and one or more of its merchants.

What happens to assignments when an owner updates them? The update replaces all previous merchant assignments with the new list; the employee then sees only the new merchants.

Can an owner assign a merchant they don't own? No - the system validates that the owner owns the organization and every listed merchant before any grant is written.

How does an employee get a password? Set-password mail is sent on creation (and when a username is added on update); employees set their own password. Reset-password mail is available on request.

Is a removed employee deleted permanently? No - removal is a soft-delete; the account is deactivated and data is preserved.

References

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.