Skip to content

Latest commit

 

History

History
158 lines (126 loc) · 2.76 KB

users.md

File metadata and controls

158 lines (126 loc) · 2.76 KB

Login

Login a user

URL : /api/users/login

Method : POST

Authentication : Logged out

Data Constraints

{
  "email": "(STRING - REQUIRED) The email of the user",
  "password": "(STRING - REQUIRED) The unhashed password of the user",
  "sessionId": "(STRING - OPTIONAL) The current session id"
}

Response Code

200: OK
400: Argument Validation Errors
400: User not found
401: Unauthorized
500: Database Error

Success Response

{
  "status": "200",
  "response": {
    "id": "1",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
  }
}

Error Response

{
  "status": "400",
  "response": {
    "error": "Invalid email/password"
  }
}

{
  "status": "400",
  "response": {
    "error": "User not found"
  }
}

{
  "status": "401",
  "response": {
    "error": "Already logged in"
  }
}

{
  "status": "500",
  "response": {
    "error": "Mybatis error"
  }
}

Register

Register a user

URL : /api/users/register

Method : POST

Authentication : Logged out

Data Constraints

{
  "name": "(STRING - REQUIRED) The name of the new user",
  "email": "(STRING - REQUIRED) The email of the user",
  "phone": "(STRING - REQUIRED) The phone of the user",
  "password1": "(STRING - REQUIRED) The unhashed password1 of the user",
  "password2": "(STRING - REQUIRED) The unhashed password2 of the user"
}

Response Code

200: OK
400: Argument Validation Errors
400: User already exists
401: Unauthorized
500: Database Error

Success Response

{
  "status": "200",
  "response": {
    "id": "1",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
  }
}

Error Response

{
  "status": "400",
  "response": {
    "error": "Invalid email/password"
  }
}

{
  "status": "400",
  "response": {
    "error": "User already exists"
  }
}

{
  "status": "401",
  "response": {
    "error": "Already logged in"
  }
}

{
  "status": "500",
  "response": {
    "error": "Mybatis error"
  }
}