longdepchai173 / supermarket_be

0 stars 0 forks source link

API [Authentication] - Create Staff Account #3

Open PhucHoangVan opened 10 months ago

PhucHoangVan commented 10 months ago

[API Description]

API Create Staff Account

description: API cho phép Admin tạo tài khoản cho nhân viên Base URL: [POST] api/accounts/create-staff-account Used By: ADMIN (check role Admin in JWT Token)

Validate:

status = ["ACTIVE", "BLOCK"] status default "ACTIVE"

role = ["STAFF", "ADMIN"] role default "STAFF"

position = ["SELL", "WAREHOUSE", "ACCOUNTANT"]

email UNIQUE()

password MIN(6 chars) password hashed

Parameters Request:

Parameters Description
Không Không

Body Request:

{
    "name": "string",
    "email": "string",
    "password": "string",
    "gender": "boolean",
    "role": "STAFF",
    "phone": "string",
    "position": "string",
    "hasWarehouse": "boolean",
    "hasShelf": "boolean",
    "hasSupply": "boolean",
    "hasAudit": "boolean",
    "hasStatistic": "boolean",
    "hasCategory": "boolean"
}

Expected Response:

{
    "statusCode": 201,
    "data": {
        "name": "string",
        "email": "string",
        "password": "xxxxx-xxxx-xxxx",
        "date_of_birth": null,
        "gender": "boolean",
        "role": "STAFF",
        "status": "ACTIVE",
        "phone": "string",
        "position": "string",
        "hasWarehouse": "boolean",
        "hasShelf": "boolean",
        "hasSupply": "boolean",
        "hasAudit": "boolean",
        "hasStatistic": "boolean",
        "hasCategory": "boolean"
    }
}

Errors

This API uses the following error codes:

Example Error Response:

{
    "statusCode": 400,
    "data": {
             "message": "The error message"
    }
}
PhucHoangVan commented 10 months ago

Trường hợp kiểm tra JWT token để xác nhận vai trò là Admin. nếu người dùng không phải là Admin thì trả về lỗi HTTP Error 403 Forbidden

Example:

{
    "statusCode": 403,
    "data": {
             "message": "You do not have access to this resource."
    }
}