Add forgot-password SMS reset, client/staff user lists, and regenerate Swagger.

Fold follow-up migrations into init, expose GET /users/clients and /users/staff, and refresh seed data.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-14 16:42:47 +05:00
parent 5e3c46da83
commit 514b9ca5fc
24 changed files with 1477 additions and 473 deletions

View File

@@ -1673,6 +1673,98 @@ const docTemplate = `{
}
}
},
"/forgot-password": {
"post": {
"description": "Finds the user by name and sends an SMS verification code",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Forgot password",
"parameters": [
{
"description": "Forgot password payload",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/auth.ForgotPasswordDTO"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/appresult.AppSuccess"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/appresult.AppError"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/appresult.AppError"
}
}
}
}
},
"/forgot-password/verify": {
"post": {
"description": "Confirms the SMS code and sets a new password",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Reset password",
"parameters": [
{
"description": "Reset password payload",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/auth.ResetPasswordDTO"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/appresult.AppSuccess"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/appresult.AppError"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/appresult.AppError"
}
}
}
}
},
"/loan-orders": {
"get": {
"security": [
@@ -3200,7 +3292,7 @@ const docTemplate = `{
},
"/login": {
"post": {
"description": "Authenticates a user by email and password",
"description": "Authenticates a user by name or phone, and password",
"consumes": [
"application/json"
],
@@ -5221,7 +5313,7 @@ const docTemplate = `{
"BearerAuth": []
}
],
"description": "Returns paginated users with optional filters",
"description": "Returns paginated users with role user, with optional filters",
"produces": [
"application/json"
],
@@ -5322,29 +5414,22 @@ const docTemplate = `{
}
}
},
"/users/role": {
"/users/clients": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Returns paginated users filtered by role",
"description": "Returns paginated users from the users table with role user",
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "List users by role",
"summary": "List client users",
"parameters": [
{
"type": "string",
"description": "user role",
"name": "role",
"in": "query",
"required": true
},
{
"type": "string",
"description": "Filter by username",
@@ -5379,8 +5464,61 @@ const docTemplate = `{
"$ref": "#/definitions/appresult.AppError"
}
},
"404": {
"description": "Not Found",
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/appresult.AppError"
}
}
}
}
},
"/users/staff": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Returns paginated users assigned to branches (from branch_user), including each user's branches.",
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "List staff users",
"parameters": [
{
"type": "string",
"description": "Filter by username",
"name": "username",
"in": "query"
},
{
"type": "integer",
"default": 1,
"description": "Page number",
"name": "page",
"in": "query"
},
{
"type": "integer",
"default": 10,
"description": "Items per page",
"name": "limit",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/appresult.AppSuccess"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/appresult.AppError"
}
@@ -5589,18 +5727,31 @@ const docTemplate = `{
}
}
},
"auth.ForgotPasswordDTO": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string"
}
}
},
"auth.LoginDTO": {
"type": "object",
"required": [
"email",
"password"
],
"properties": {
"email": {
"name": {
"type": "string"
},
"password": {
"type": "string"
},
"phone": {
"type": "string"
}
}
},
@@ -5644,6 +5795,30 @@ const docTemplate = `{
}
}
},
"auth.ResetPasswordDTO": {
"type": "object",
"required": [
"code",
"name",
"password",
"passwordConfirm"
],
"properties": {
"code": {
"type": "string"
},
"name": {
"type": "string"
},
"password": {
"type": "string",
"minLength": 6
},
"passwordConfirm": {
"type": "string"
}
}
},
"auth.UpdateProfileDTO": {
"type": "object",
"required": [