User /api/user

Base route: /api/user

📚 Read more about Authentication and Session in the Back-end Server Architecture Authentication & Session documentation.

Table of contents

  1. /createUser
    1. Request Schema
    2. Sample Schema
    3. Success Response Schema
    4. Success Sample Schema
    5. Failure Response Schema
    6. Failure Response Sample
  2. /validateUser
    1. Request Schema
    2. Sample Schema
    3. Success Response Schema
    4. Success Sample Schema
    5. Failure Response Schema
    6. Failure Response Sample

/createUser

Description Create a new user.
HTTP Verb POST
Success Codes 200
Failure Codes 500 server error

Request Schema

{
    "email": string,
    "password": string
}

Sample Schema

{
    "email": "yvrUser@xyz.com",
    "password": "yvrPassword!1"
}

Success Response Schema

{
    "_id": string,
    "email": string,
    "password": string, // password is hashed
    "role": string,
}

Success Sample Schema

{
    "_id": "1234eigh89b02749e3a41c34",
    "email": "yvrUser@xyz.com",
    "password": "$8z$80$3Qx5XB.VtrpqLQTRfu2bquJZ2AZIA39O4BrkTlUfqN3dhiJ3yT49W",
    "role": "User",
}

Failure Response Schema

{ "message": string }

Failure Response Sample

{ "message": <MESSAGE_GIVEN_CONDITION>}
Condition Message
If missing email or password. “Invalid request: email and password are required.”
If another error occurs (ex. passing the wrong data type in the body). “There was an error with the request.”

/validateUser

Description Validate a user for login.
HTTP Verb POST
Success Codes 200
Failure Codes 500 server error

Request Schema

{
    "email": string,
    "password": string
}

Sample Schema

{
    "email": "yvrUser@xyz.com",
    "password": "yvrPassword!1"
}

Success Response Schema

{
    "_id": string,
    "email": string,
    "password": string,
    "role": string,
}

Success Sample Schema

{
    "_id": "1234eigh89b02749e3a41c34",
    "email": "yvrUser@xyz.com",
    "password": "$8z$80$3Qx5XB.VtrpqLQTRfu2bquJZ2AZIA39O4BrkTlUfqN3dhiJ3yT49W",
    "role": "User",
}

Failure Response Schema

{ "message": string }

Failure Response Sample

{ "message": <MESSAGE_GIVEN_CONDITION>}
Condition Message
If missing email or password. “Invalid request: email and password are required.”
Invalid login credentials. “User with this email and password combination does not exist.”
If another error occurs (ex. passing the wrong data type in the body). “There was an error with the request.”