Registration Flow
User submits registration form
Users provide an email, password (minimum 8 characters), and display name.
Registration Request
System validates registration mode
Anchor checks the current registration mode (enabled, review, or disabled):
- Enabled: User is created with
activestatus and can log in immediately - Review: User is created with
pendingstatus and must wait for approval - Disabled: Registration is rejected with 403 error
Password is hashed and user is created
The password is securely hashed using bcrypt with 10 salt rounds before storing in the database.
The first user to register automatically becomes an administrator.
Login Flow
System validates credentials
The server:
- Finds the user by email
- Verifies the password hash matches
- Checks the user’s status
Token Management
Access Token Refresh
Access tokens are short-lived for security. Use the refresh token to obtain new access tokens:Refresh Token
Anchor implements token rotation: each refresh invalidates the old refresh token and issues a new one.
Logout
Revoke a refresh token to log out:Logout
API Token Management
For programmatic access, users can generate persistent API tokens:Password Management
Changing Password
Authenticated users can change their password:Change Password
Password Requirements
- Minimum 8 characters
- New password must differ from current password
- Passwords are hashed with bcrypt (10 rounds)
Profile Management
Update Profile
Users can update their display name:Update Profile
Profile Image Upload
Upload a profile picture (max 5MB, JPEG/PNG/WebP):Upload Profile Image
- JPEG (image/jpeg)
- PNG (image/png)
- WebP (image/webp)
- Maximum file size: 5MB
Remove Profile Image
Remove Profile Image
Error Handling
401 Unauthorized
401 Unauthorized
403 Forbidden
403 Forbidden
Registration disabled or account pendingOr for pending accounts:
409 Conflict
409 Conflict
Email already registered
Security Features
Bcrypt Hashing
All passwords are hashed using bcrypt with 10 salt rounds before storage.
Token Rotation
Refresh tokens are rotated on each use to prevent replay attacks.
Token Expiration
Refresh tokens expire after 90 days. Expired tokens are automatically deleted.
Secure Sessions
JWT tokens are signed with a secret key. Database-backed refresh tokens prevent token theft.
Implementation Reference
The local authentication implementation can be found in:- Controller:
server/src/auth/auth.controller.ts - Service:
server/src/auth/auth.service.ts - DTOs:
server/src/auth/dto/
Next Steps
User Management
Configure registration modes and approve users
OIDC Setup
Add enterprise SSO with OIDC