Home / Docs Center / Pet Feeder (ODM Case) / User Module

User Module

Pet Feeder (ODM Case) · App Server-Side API

Project: Pet Feeder | page_id: 1722

User Authentication Interface Documentation

Overview

  • Base path: /api
  • Documentation scope: only includes user interfaces that require JWT authentication
  • Authentication method:
  • The request header X-Token is read first
  • Content-Type: application/json

Unified Response Format

{
  "code": 200,
  "msg": "Operation successful",
  "data": {}
}

Response Field Description

Field Type Description
code integer Business status code; 200 means success, other values mean failure
msg string Response message
data object/null Business data, may be an object, an array or null

Common Authentication Failure Response Example

{
  "code": 401,
  "msg": "Not logged in or login expired",
  "data": null
}
{
  "code": 401,
  "msg": "Login has expired, please log in again",
  "data": null
}

1. User Logout

  • Path: /api/user/logout
  • Method: POST
  • Authentication required: Yes

Request Headers

Field Type Required Description
X-Token string Yes Pass in the JWT token directly

Description:

  • This interface is a stateless logout. The server does not maintain a blacklist; the client deleting the token is regarded as a logout.

Request Body

No business parameters; an empty object can be passed:

{}

Success Response Example

{
  "code": 200,
  "msg": "Logout successful",
  "data": null
}

Response Parameter Description

Field Type Description
code integer Fixed to 200
msg string Fixed to Logout successful
data null No returned data

2. Refresh Token

  • Path: /api/user/refreshToken
  • Method: POST
  • Authentication required: Yes

Request Headers

Field Type Required Description
X-Token string Yes Pass in the JWT token directly

Request Body

The current implementation does not read the business request body; an empty object can be passed:

{}

Success Response Example

{
  "code": 200,
  "msg": "Refresh successful",
  "data": {
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.xxx.yyy",
    "expiresIn": 86400
  }
}

Response Parameter Description

Field Type Description
code integer Fixed to 200
msg string Fixed to Refresh successful
data.token string The newly generated JWT Token
data.expiresIn integer Remaining valid seconds of the Token

Failure Response Example

{
  "code": 400,
  "msg": "User does not exist",
  "data": null
}

3. Change Password

  • Path: /api/user/changePassword
  • Method: POST
  • Authentication required: Yes

Request Headers

Field Type Required Description
X-Token string Yes Pass in the JWT token directly

Request Body Parameters

Field Type Required Description
oldPassword string Yes Old password. If the user has set a password before, it must match the current password
newPassword string Yes New password; the server stores it encrypted

Request Example

{
  "oldPassword": "12345678",
  "newPassword": "newPass@2026"
}

Success Response Example

{
  "code": 200,
  "msg": "Password changed successfully",
  "data": null
}

Response Parameter Description

Field Type Description
code integer Fixed to 200
msg string Fixed to Password changed successfully
data null No returned data

Failure Response Example

{
  "code": 400,
  "msg": "Parameter error",
  "data": null
}
{
  "code": 400,
  "msg": "Incorrect current password",
  "data": null
}
{
  "code": 400,
  "msg": "User does not exist",
  "data": null
}

4. Change Nickname

  • Path: /api/user/updateNickname
  • Method: POST
  • Authentication required: Yes

Request Headers

Field Type Required Description
X-Token string Yes Pass in the JWT token directly

Request Body Parameters

Field Type Required Description
nickname string Yes New nickname; cannot be empty and can be at most 30 characters

Request Example

{
  "nickname": "New nickname"
}

Success Response Example

{
  "code": 200,
  "msg": "Nickname changed successfully",
  "data": null
}

Response Parameter Description

Field Type Description
code integer Fixed to 200
msg string Fixed to Nickname changed successfully
data null No returned data

Failure Response Example

{
  "code": 400,
  "msg": "Parameter error",
  "data": null
}
{
  "code": 400,
  "msg": "Nickname cannot be empty",
  "data": null
}
{
  "code": 400,
  "msg": "The nickname cannot exceed 30 characters",
  "data": null
}

Appendix

Authentication Header Usage Example

X-Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.xxx.yyy

Description

  • All interface responses use a unified structure in which the business code is placed in the code field.
  • Except for the FailWithHTTP scenario, most business failures still return HTTP 200; the client should use the code field to determine whether the call succeeded.
  • The refresh Token interface currently only depends on the logged-in user identity and does not read the refreshToken request body field.
Didn't find what you need?Contact us,Talk to our engineers directly.

Request a Quote

Fill in the form and we will get back with a quote and proposal within 1 business day.

Click "Generate inquiry email" to open your mail client with the body pre-filled. If no mail client is configured, click "Copy" and paste it into webmail — recipient: sunshiyang@xstrive.com.