mirror of
https://github.com/open-reception/appointment-booking-software.git
synced 2026-08-28 10:49:39 +02:00
2.2 KiB
2.2 KiB
Admin Registration API Usage
Flow Overview
- POST /api/admin/register - Create admin account
- POST /api/admin/confirm - Confirm account via email token
- POST /api/admin/resend-confirmation - Resend confirmation email
API Endpoints
1. Register Admin
POST /api/admin/register
Content-Type: application/json
{
"name": "Admin Name",
"email": "admin@example.com",
"passkey": {
"id": "credential-id-from-webauthn",
"publicKey": "base64-encoded-public-key",
"counter": 0,
"deviceName": "MacBook Pro"
}
}
Response (201):
{
"message": "Admin account created successfully. Please check your email for confirmation.",
"adminId": "01234567-89ab-cdef-0123-456789abcdef",
"email": "admin@example.com"
}
2. Confirm Admin Account
POST /api/admin/confirm
Content-Type: application/json
{
"token": "01234567-89ab-cdef-0123-456789abcdef"
}
Response (200):
{
"message": "Admin account confirmed successfully. You can now log in."
}
3. Resend Confirmation Email
POST /api/admin/resend-confirmation
Content-Type: application/json
{
"email": "admin@example.com"
}
Response (200):
{
"message": "Confirmation email resent successfully. Please check your email."
}
Error Responses
400 Bad Request
{
"error": "Invalid admin data"
}
404 Not Found
{
"error": "Invalid or expired confirmation token"
}
409 Conflict
{
"error": "An admin with this email already exists"
}
500 Internal Server Error
{
"error": "Internal server error"
}
Implementation Notes
- Admin accounts are created as
isActive: falseandconfirmed: false - Confirmation tokens expire after 10 minutes
- Email sending is marked as TODO in the service layer
- After confirmation, admin becomes
isActive: trueandconfirmed: true - Passkey is stored during registration and linked to the admin account
- The passkey
idfield is the credential ID from WebAuthn registration - The passkey
publicKeyfield must be base64 encoded - The passkey
counterfield defaults to 0 if not provided - The passkey
deviceNamefield defaults to "Unknown Device" if not provided