Skip to content

Work in Progress

Feature details in this document may change during investigation, discussion, design, and implementation phases.

User Management / Quản lý User

Manage internal operators, business owners, and staff accounts.

Overview

AttributeValue
Module IDCORE-01
PhasePhase 1 (Internal + Owner), Phase 2 (Staff + Custom Roles)
PriorityHIGH
DependenciesNone (Foundation module)

The User Management module provides comprehensive account management for three user types: Internal Users (system operators), Owners (business owners/Chủ hộ), and Staff (employees). It supports hierarchical user structures with clear separation between internal operations and merchant-facing functionality.

User Types

TypeDescriptionScope
InternalVNPAY employees who operate and manage the systemSystem-wide
ExternalBusiness owners and their employeesPer Organization
┌─────────────────────────────────────────────────────────────────────────────┐
│                           USER HIERARCHY                                    │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                             │
│  ┌─────────────────────────────────────────────────────────────────────┐    │
│  │                    INTERNAL USERS (System)                          │    │
│  │                                                                     │    │
│  │    ┌───────────────┐                                                │    │
│  │    │  SUPER ADMIN  │  ← Full system access, user management         │    │
│  │    └───────┬───────┘                                                │    │
│  │            │                                                        │    │
│  │    ┌───────┴───────┐                                                │    │
│  │    ▼               ▼                                                │    │
│  │  ┌─────────┐  ┌─────────┐                                           │    │
│  │  │  ADMIN  │  │  ADMIN  │  ← Manage merchants, support operations   │    │
│  │  └────┬────┘  └────┬────┘                                           │    │
│  │       │            │                                                │    │
│  │  ┌────┴────┐  ┌────┴────┐                                           │    │
│  │  │OPERATOR │  │OPERATOR │  ← Day-to-day operations, reports         │    │
│  │  └─────────┘  └─────────┘                                           │    │
│  │                                                                     │    │
│  └─────────────────────────────────────────────────────────────────────┘    │
│                                    │                                        │
│                                    │ manages                                │
│                                    ▼                                        │
│  ┌─────────────────────────────────────────────────────────────────────┐    │
│  │                    EXTERNAL USERS (Merchants)                       │    │
│  │                                                                     │    │
│  │    ┌──────────────┐                                                 │    │
│  │    │    OWNER     │  ← Business owner (Chủ hộ kinh doanh)           │    │
│  │    └──────┬───────┘    Can create custom roles                      │    │
│  │           │                                                         │    │
│  │    ┌──────┴───────┬─────────────┐                                   │    │
│  │    ▼              ▼             ▼                                   │    │
│  │  ┌─────────┐  ┌─────────┐  ┌──────────┐                             │    │
│  │  │  STAFF  │  │  STAFF  │  │ CUSTOM   │  ← Dynamically created      │    │
│  │  │ (Store1)│  │ (Store2)│  │  ROLES   │    by Owner                 │    │
│  │  └─────────┘  └─────────┘  └──────────┘                             │    │
│  │                                                                     │    │
│  └─────────────────────────────────────────────────────────────────────┘    │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

Internal User Roles

RoleDescriptionCapabilities
Super AdminHighest privilege levelFull system access, manage all internal users, system configuration
AdminOperations administratorManage merchants, handle escalations, configure features
OperatorOperations staffDay-to-day support, view reports, assist merchants

External User Roles

Default Roles

When an Organization is created, two default roles are automatically provisioned:

RoleDescriptionConfigurable
OwnerBusiness owner with full access to their organizationNo (system role)
StaffDefault employee role with basic POS accessYes

Custom Roles

Owners can create additional custom roles with configurable permissions to match their business structure:

Example RoleUse Case
Store ManagerFull store access, staff management, reports
CashierPOS only, limited reports
Inventory ManagerStock management, no sales access
AccountantReports and transactions, no POS

User Stories

Internal Users

IDAs a...I want to...So that...
US-INT-01Super AdminCreate and manage Admin accountsI can delegate system management
US-INT-02Super AdminConfigure system-wide settingsThe platform operates correctly
US-INT-03Super AdminView all merchant dataI can oversee platform operations
US-INT-04AdminCreate and manage Operator accountsDay-to-day tasks are handled
US-INT-05AdminManage merchant accountsI can support business owners
US-INT-06AdminHandle support escalationsIssues are resolved promptly
US-INT-07OperatorView merchant reportsI can assist with inquiries
US-INT-08OperatorAccess support toolsI can help merchants effectively

External Users - Owner (Chủ hộ)

IDAs a...I want to...So that...
US-OWN-01Business ownerRegister my account with business infoI can start using the POS system
US-OWN-02Business ownerVerify my phone/emailMy account is secure
US-OWN-03Business ownerConfigure my business profile (name, MST)Tax invoices are correct
US-OWN-04Business ownerEnable two-factor authenticationMy account is protected
US-OWN-05Business ownerView my login historyI can detect unauthorized access
US-OWN-06Business ownerCreate custom rolesI can match my business structure
US-OWN-07Business ownerConfigure role permissionsEach role has appropriate access

External Users - Staff & Custom Roles

IDAs a...I want to...So that...
US-STF-01Business ownerCreate staff accountsEmployees can use the system
US-STF-02Business ownerAssign staff to specific storesEach staff works at correct location
US-STF-03Business ownerAssign roles to staffStaff have appropriate permissions
US-STF-04Business ownerDeactivate staff accountsFormer employees lose access
US-STF-05Staff memberLogin with my credentialsI can perform my work tasks
US-STF-06Staff memberAccess features based on my roleI can do my assigned tasks

Feature Matrix

Internal User Features

FeatureP1P2P3Description
Super Admin accountInitial system administrator
Admin account managementCreate/manage Admin users
Operator account managementCreate/manage Operator users
System configurationPlatform-wide settings
Merchant managementView/manage all merchants
Internal audit logsTrack internal user actions

External User Features (Owner)

FeatureP1P2P3Description
Owner registrationRegister with phone/email
Business profile setupName, MST, address, hours
Phone/Email verificationOTP verification
Password managementSet/reset password
Two-factor auth (2FA)Optional SMS/Authenticator
Login historyTrack login attempts
Session managementActive sessions control

External User Features (Staff & Roles)

FeatureP1P2P3Description
Staff account creationCreate employee accounts
Staff store assignmentAssign to Merchant/POS
Role assignmentAssign roles to staff
Staff deactivationSuspend/remove access
Custom role creationOwner creates custom roles
Permission configurationConfigure role permissions
Staff activity trackingPerformance metrics

Key Flows

Internal User Management Flow

Owner Registration Flow

Custom Role Creation Flow

Staff Account Creation Flow

User Session State


Business Rules

Internal Users

Rule IDRuleDescription
BR-INT-01Super Admin minimumAt least 1 Super Admin must exist
BR-INT-02Role hierarchySuper Admin > Admin > Operator
BR-INT-03Self-demotionUsers cannot demote themselves
BR-INT-04Audit loggingAll internal actions must be logged

External Users (Owner)

Rule IDRuleDescription
BR-OWN-01Phone requiredPhone number is mandatory for registration
BR-OWN-02Unique phoneEach phone number can only register once
BR-OWN-03MST formatTax ID must follow Vietnam MST format (10 or 13 digits)
BR-OWN-04Password policyMin 8 chars, 1 uppercase, 1 number
BR-OWN-05OTP expiryOTP valid for 5 minutes
BR-OWN-06Login attemptsLock after 5 failed attempts (30 min)
BR-OWN-07Session timeoutAuto logout after 30 min inactive
BR-OWN-08Owner uniqueEach organization has exactly 1 owner account

External Users (Staff & Roles)

Rule IDRuleDescription
BR-STF-01Staff limitMax 100 staff per organization (configurable)
BR-STF-02Staff requires storeStaff must be assigned to at least 1 Merchant
BR-STF-03Staff requires roleStaff must have at least 1 role assigned
BR-STF-04Multiple rolesStaff can have multiple roles assigned
BR-STF-05Direct permissionsStaff can have direct permissions via PermissionMapping
BR-STF-06Default roles immutableOwner role cannot be modified or deleted
BR-STF-07Role limitMax 20 custom roles per organization
BR-STF-08Role in useCannot delete role if assigned to staff
BR-STF-09Effective permissionsStaff effective perms = Union(role perms) + direct perms

Acceptance Criteria

AC-INT-01: Internal User Creation

GIVEN   a Super Admin or Admin logged into Admin Portal
WHEN    they create a new internal user (Admin/Operator)
THEN    - Account is created with specified role
        - Credentials are generated securely
        - User can login to Admin Portal
        - Action is logged in audit trail

AC-OWN-01: Owner Registration

GIVEN   a new user with valid phone number
WHEN    they complete registration with business info
THEN    - Account is created with OWNER role
        - Organization is created
        - Default roles (Owner, Staff) are created
        - Business profile is saved
        - User can login immediately
        - MST is validated (format check)

AC-OWN-02: Phone Verification

GIVEN   a user entering phone number
WHEN    OTP is sent
THEN    - OTP is 6 digits
        - OTP expires in 5 minutes
        - Max 3 OTP requests per 15 minutes
        - User cannot proceed without verification

AC-OWN-03: Two-Factor Authentication

GIVEN   an owner with 2FA enabled
WHEN    they login with correct password
THEN    - 2FA prompt appears
        - Login only succeeds after 2FA verification
        - Trusted devices can skip 2FA (optional)

AC-ROLE-01: Custom Role Creation

GIVEN   an owner logged into the system
WHEN    they create a custom role
THEN    - Role is created with specified name
        - Permissions are assigned to role
        - Role is available for staff assignment
        - Role count does not exceed limit (20)

AC-ROLE-02: Role Permission Configuration

GIVEN   an owner with an existing custom role
WHEN    they modify role permissions
THEN    - Permissions are updated
        - All staff with this role inherit new permissions
        - Changes take effect immediately

AC-STF-01: Staff Account Creation

GIVEN   an owner logged into the system
WHEN    they create a staff account
THEN    - Staff receives login credentials
        - Staff is assigned to selected store(s)
        - Staff is assigned at least one role
        - Staff can login and work

AC-STF-02: Staff Role Assignment

GIVEN   an owner with existing staff and roles
WHEN    they assign roles to a staff member
THEN    - Selected roles are assigned (can be multiple)
        - Staff inherits union of all role permissions
        - Changes take effect immediately

AC-STF-03: Direct Permission Assignment

GIVEN   an owner managing a staff member's permissions
WHEN    they add a direct permission
THEN    - Permission is added via PermissionMapping
        - Staff receives permission independent of roles
        - Effective permissions updated immediately

AC-STF-04: Account Deactivation

GIVEN   a staff account that needs to be disabled
WHEN    owner deactivates the account
THEN    - Staff is immediately logged out
        - Staff cannot login
        - Staff data is retained (soft delete)
        - Can be reactivated later

Dependencies

User Management
├── Required by: Permissions, Organization, Merchant
├── Requires: None (Foundation)
├── Contains: Role Management (embedded)
└── Integrates: VNPAY MO (Merchant Onboarding)
ModuleRelationship
PermissionsRoles contain permissions, Users inherit via Role
OrganizationOwner belongs to Organization, Roles scoped to Organization
MerchantStaff assigned to Merchants

Integration Points

Admin Portal (Internal Users)

┌─────────────────────────────────────────────────────────┐
│                    ADMIN PORTAL                         │
├─────────────────────────────────────────────────────────┤
│                                                         │
│  Internal Users (Super Admin, Admin, Operator)          │
│                                                         │
│  Access:                                                │
│  ├── Separate authentication system                     │
│  ├── Admin-specific web portal                          │
│  ├── Audit logging for all actions                      │
│  └── Role-based access to system features               │
│                                                         │
│  Capabilities:                                          │
│  ├── View/manage all merchants                          │
│  ├── System configuration                               │
│  ├── Support operations                                 │
│  └── Reports and analytics                              │
│                                                         │
└─────────────────────────────────────────────────────────┘

VNPAY Merchant Onboarding (MO)

┌─────────────────────────────────────────────────────────┐
│                    VNPAY MO SYNC                        │
├─────────────────────────────────────────────────────────┤
│                                                         │
│  Sales Connect → MO → PMBH                           │
│                                                         │
│  Sync Data:                                             │
│  ├── Business information                               │
│  ├── Owner contact details                              │
│  ├── Tax registration (MST)                             │
│  └── Store/outlet information                           │
│                                                         │
│  Trigger: When merchant is approved in MO               │
│  Direction: MO → PMBH (one-way sync)                 │
│  Result: Owner account + default roles created          │
│                                                         │
└─────────────────────────────────────────────────────────┘

Screenshots

Screenshots

Screenshots will be added after UI implementation.


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