Skip to content

๐Ÿ” Authentication API โ€‹

๐Ÿ“ Customer Registration โ€‹

POST /api/auth/customer/register

Request:

json
{
  "name": "Jane Doe",
  "email": "jane@example.com",
  "password": "securepassword",
  "phone": "+1234567890"
}

Response: 201 Created

json
{
  "success": true,
  "data": {
    "token": "eyJhbG...",
    "customer": {
      "id": "cuid",
      "name": "Jane Doe",
      "email": "jane@example.com"
    }
  }
}

๐Ÿ”‘ Customer Login โ€‹

POST /api/auth/customer/login

Request:

json
{
  "email": "jane@example.com",
  "password": "securepassword"
}

Response: 200 OK

json
{
  "success": true,
  "data": {
    "token": "eyJhbG...",
    "customer": {
      "id": "cuid",
      "name": "Jane Doe",
      "email": "jane@example.com"
    }
  }
}

๐Ÿ‘จโ€๐Ÿ’ผ Staff Login โ€‹

POST /api/auth/staff/login

Request:

json
{
  "email": "admin@kitchenasty.com",
  "password": "admin123"
}

Response: 200 OK

json
{
  "success": true,
  "data": {
    "token": "eyJhbG...",
    "user": {
      "id": "cuid",
      "name": "Admin",
      "email": "admin@kitchenasty.com",
      "role": "SUPER_ADMIN"
    }
  }
}

๐Ÿ‘ฅ Staff Registration โ€‹

POST /api/auth/staff/register
Authorization: Bearer <super-admin-token>

Only Super Admins can create new staff accounts.

Request:

json
{
  "name": "New Staff",
  "email": "staff@kitchenasty.com",
  "password": "password123",
  "role": "STAFF",
  "locationId": "location-id"
}

๐Ÿ‘ค Get Current User โ€‹

GET /api/auth/me
Authorization: Bearer <token>

Returns the currently authenticated user (staff or customer).

Response: 200 OK

json
{
  "success": true,
  "data": {
    "id": "cuid",
    "email": "user@example.com",
    "name": "User Name",
    "type": "staff",
    "role": "MANAGER"
  }
}

๐Ÿ”ต Google OAuth โ€‹

GET /api/auth/google

Redirects the user to Google's OAuth consent screen. After approval, redirects to /api/auth/google/callback which issues a JWT token.

Only available when GOOGLE_CLIENT_ID is configured.

๐Ÿ”ท Facebook OAuth โ€‹

GET /api/auth/facebook

Redirects the user to Facebook's login dialog. After approval, redirects to /api/auth/facebook/callback which issues a JWT token.

Only available when FACEBOOK_APP_ID is configured.

โš ๏ธ Error Cases โ€‹

ScenarioStatusError
โŒ Invalid credentials401Invalid email or password
๐Ÿ“ง Email already exists400Email already registered
๐Ÿ“‹ Missing required fields400Validation error message
๐Ÿšซ Unauthorized staff registration403Forbidden