Creating Authenticated Users
Context & Background
This requirement covers the creation of authenticated users (Protectors and RPOs) who can access the Digital Lock On platform with email and password authentication through Clerk.
User Story
As an administrator, I want to create authenticated users so that Protectors and RPOs can access the Digital Lock On platform with proper authentication credentials.
Business Rules
- Only user types "Protector" and "RPO" can be created as authenticated users
- All authenticated users must have a corresponding Clerk account for token generation
- All authenticated users must be created as Users in the Digital Lock On platform
- Email addresses must be unique across all authenticated users
- User creation requires both Clerk account creation and Digital Lock On user record creation
- Admin platform access is required to create authenticated users
Acceptance Criteria
Successful User Creation
- [ ] Admin can create a new Protector user with email and password
- [ ] Admin can create a new RPO user with email and password
- [ ] Clerk account is created with the provided email and password
- [ ] Digital Lock On user record is created with all required fields from User interface
- [ ] User receives email confirmation from Clerk (if configured)
- [ ] Created user can successfully authenticate and access appropriate platform features
Required User Data
- [ ] Email address (required) - used for Clerk authentication
- [ ] Password (required) - used for Clerk authentication
- [ ] Name (required) - stored in Digital Lock On user record
- [ ] Mobile number (required) - stored in Digital Lock On user record
- [ ] Company (required) - stored in Digital Lock On user record
- [ ] User type (required) - must be "Protector" or "RPO"
Validation Requirements
- [ ] Email address format is validated
- [ ] Email address uniqueness is enforced
- [ ] Password meets minimum security requirements
- [ ] Mobile number format is validated
- [ ] User type is restricted to "Protector" or "RPO"
- [ ] All required fields are provided before creation
Error Handling
- [ ] Clear error message when email already exists in Clerk
- [ ] Clear error message when email already exists in Digital Lock On platform
- [ ] Clear error message for invalid password requirements
- [ ] Clear error message for invalid email format
- [ ] Clear error message for invalid mobile number format
- [ ] Rollback mechanism if Clerk creation succeeds but Digital Lock On creation fails
- [ ] Rollback mechanism if Digital Lock On creation succeeds but Clerk creation fails
Dependencies
- Clerk authentication service must be available and configured
- Digital Lock On platform user management API must be available
- User type definitions must be consistent between admin platform and Digital Lock On platform
Implementation Notes
- User creation should be transactional - both Clerk and Digital Lock On records must be created successfully
- Consider using Clerk user metadata to store the Digital Lock On user ID for linking
- Email field should be optional in Digital Lock On user record since it's managed by Clerk
- LastLoginAt field will be populated when user first authenticates
Notes
- This requirement covers the admin-initiated user creation flow
- Users created through this process will be able to generate access tokens via Clerk
- Audit trail for user creation will be addressed in Decision: Audit Trail Strategy
- User updates and deletion are covered in separate requirements