Update the user's profile information

PATCH /api/profile/updateprofile

The JWT token in the 'jwt' cookie is verified by the verifyJWT middleware. If valid, the user's ID is extracted from the token and added to request.body.userId. The updateProfile controller then updates the user's profile information and returns the updated user data.

application/json

Body Required

  • firstName string
  • lastName string
  • theme number

Responses

  • 200 application/json

    Profile updated successfully

    Hide response attribute Show response attribute object
    • user object
      Hide user attributes Show user attributes object
      • id string
      • email string
      • configuredProfile boolean
      • firstName string
      • lastName string
      • avatar string
      • theme number
  • 400 text/plain

    Bad Request, missing required fields

  • 401 text/plain

    Unauthorized, JWT cookie is missing

  • 403 text/plain

    Forbidden, JWT token is invalid

  • 404 text/plain

    User not found

  • 500 text/plain

    Internal server error

PATCH /api/profile/updateprofile
curl \
 --request PATCH 'http://localhost:xxxx/api/profile/updateprofile' \
 --cookie "jwt=$API_KEY" \
 --header "Content-Type: application/json" \
 --data '{"firstName":"约翰","lastName":"多伊","theme":1}'
Request examples
{
  "firstName": "约翰",
  "lastName": "多伊",
  "theme": 1
}
Response examples (200)
{
  "user": {
    "id": "60d0fe4f5311236168a109ca",
    "email": "user@example.com",
    "configuredProfile": true,
    "firstName": "约翰",
    "lastName": "多伊",
    "avatar": "https://example.com/avatar.jpg",
    "theme": 1
  }
}
Response examples (400)
名字、姓氏和主题均为必填项
Response examples (401)
您未通过身份验证
Response examples (403)
无效的令牌
Response examples (404)
错误
Response examples (500)
服务器内部错误