Skip to main content

register

需求描述

使用者註冊的 API 密碼要用 bcrypt hash 過後再存到資料庫 如果 email 和使用者名稱前後有空格要去除後再存入資料庫 e.g. " yupooooo123 ""yupooooo123"

Method

GET

Endpoint

  • /api/auth/register

Request Body

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

Response

註冊成功

  • HTTP Status Code: 200
{
"username": "string",
}

email 格式錯誤

  • HTTP Status Code: 422
{
"detail": [
{
"loc": [
"body",
"email"
],
"msg": "value is not a valid email address",
"type": "value_error.email"
}
]
}

使用者名稱輸入空字串

  • HTTP Status Code: 422
{
"detail": [
{
"ctx": {
"limit_value": 1
},
"loc": [
"body",
"username"
],
"msg": "ensure this value has at least 1 characters",
"type": "value_error.any_str.min_length"
}
]
}

密碼格式錯誤

  • HTTP Status Code: 422
{
"detail": [
{
"loc": [
"body",
"password"
],
"msg": "string does not match regex \"^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()_+]).{8,}$\"",
"type": "value_error.str.regex",
"ctx": {
"pattern": "^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()_+]).{8,}$"
}
}
]
}

密碼輸入空字串

  • HTTP Status Code: 422
{
"detail": [
{
"ctx": {
"limit_value": 1
},
"loc": [
"body",
"password"
],
"msg": "ensure this value has at least 1 characters",
"type": "value_error.any_str.min_length"
}
]
}

使用用過的 email 註冊

  • HTTP Status Code: 400
{
"detail": "Email already in use"
}