Add Password Reset Functionality and Update API Documentation

- Implemented password reset functionality, including endpoints for requesting a reset code, verifying the OTP, and resetting the password.
- Introduced new request and response forms for password reset operations, ensuring proper validation and structured responses.
- Enhanced the customer service layer to handle password reset requests, OTP verification, and password updates, utilizing Redis for temporary token storage.
- Updated Swagger and YAML documentation to include new API endpoints and their specifications, improving clarity for API consumers.
- Refactored the customer handler to manage new password reset routes, ensuring adherence to clean architecture principles.
This commit is contained in:
n.nakhostin
2025-09-14 13:25:36 +03:30
parent 5d721705b7
commit c701053609
9 changed files with 1213 additions and 3 deletions
+282
View File
@@ -4874,6 +4874,70 @@
}
}
},
"/api/v1/profile/forgot-password": {
"post": {
"description": "Send a password reset OTP code to the customer's email address",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Authorization"
],
"summary": "Request password reset",
"parameters": [
{
"description": "Email address for password reset",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/customer.RequestResetPasswordForm"
}
}
],
"responses": {
"200": {
"description": "Password reset code sent successfully",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/customer.RequestResetPasswordResponse"
}
}
}
]
}
},
"400": {
"description": "Bad request - Invalid input data",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"422": {
"description": "Validation error - Invalid request data",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
}
},
"/api/v1/profile/login": {
"post": {
"description": "Authenticate customer with username (email) and password. Returns access token, refresh token, and customer information upon successful authentication.",
@@ -5054,6 +5118,146 @@
}
}
},
"/api/v1/profile/reset-password": {
"post": {
"description": "Reset the customer's password using the reset token",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Authorization"
],
"summary": "Reset password",
"parameters": [
{
"description": "Email, reset token, and new password",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/customer.ResetPasswordForm"
}
}
],
"responses": {
"200": {
"description": "Password reset successfully",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/customer.ResetPasswordResponse"
}
}
}
]
}
},
"400": {
"description": "Bad request - Invalid input data",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"401": {
"description": "Unauthorized - Invalid or expired reset token",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"422": {
"description": "Validation error - Invalid request data",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
}
},
"/api/v1/profile/verify-otp": {
"post": {
"description": "Verify the OTP code received via email and get a reset token",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Authorization"
],
"summary": "Verify OTP code",
"parameters": [
{
"description": "Email and OTP code for verification",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/customer.VerifyOTPForm"
}
}
],
"responses": {
"200": {
"description": "OTP verified successfully",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/customer.VerifyOTPResponse"
}
}
}
]
}
},
"400": {
"description": "Bad request - Invalid input data",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"401": {
"description": "Unauthorized - Invalid or expired OTP",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"422": {
"description": "Validation error - Invalid request data",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
}
},
"/api/v1/tender-approvals": {
"get": {
"security": [
@@ -6432,6 +6636,54 @@
}
}
},
"customer.RequestResetPasswordForm": {
"type": "object",
"properties": {
"email": {
"type": "string",
"example": "app@opplens.com"
}
}
},
"customer.RequestResetPasswordResponse": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "Password reset code sent to your email"
},
"success": {
"type": "boolean",
"example": true
}
}
},
"customer.ResetPasswordForm": {
"type": "object",
"properties": {
"new_password": {
"type": "string",
"example": "NewPass!123"
},
"token": {
"type": "string",
"example": "reset_token_here"
}
}
},
"customer.ResetPasswordResponse": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "Password reset successfully"
},
"success": {
"type": "boolean",
"example": true
}
}
},
"customer.UpdateCustomerForm": {
"type": "object",
"properties": {
@@ -6480,6 +6732,36 @@
}
}
},
"customer.VerifyOTPForm": {
"type": "object",
"properties": {
"code": {
"type": "string",
"example": "123456"
},
"email": {
"type": "string",
"example": "app@opplens.com"
}
}
},
"customer.VerifyOTPResponse": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "OTP verified successfully"
},
"success": {
"type": "boolean",
"example": true
},
"token": {
"type": "string",
"example": "reset_token_here"
}
}
},
"feedback.CompanyFeedbackStatsResponse": {
"type": "object",
"properties": {