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:
@@ -120,3 +120,39 @@ type AssignCompaniesForm struct {
|
||||
type RemoveCompaniesForm struct {
|
||||
CompanyIDs []string `json:"company_ids" valid:"required"`
|
||||
}
|
||||
|
||||
// RequestResetPasswordForm represents the form for requesting password reset
|
||||
type RequestResetPasswordForm struct {
|
||||
Email string `json:"email" valid:"required,email" example:"app@opplens.com"`
|
||||
}
|
||||
|
||||
// VerifyOTPForm represents the form for verifying OTP code
|
||||
type VerifyOTPForm struct {
|
||||
Email string `json:"email" valid:"required,email" example:"app@opplens.com"`
|
||||
Code string `json:"code" valid:"required,length(6|6)" example:"123456"`
|
||||
}
|
||||
|
||||
// ResetPasswordForm represents the form for resetting password
|
||||
type ResetPasswordForm struct {
|
||||
Token string `json:"token" valid:"required" example:"reset_token_here"`
|
||||
NewPassword string `json:"new_password" valid:"required,length(5|128)" example:"NewPass!123"`
|
||||
}
|
||||
|
||||
// RequestResetPasswordResponse represents the response for password reset request
|
||||
type RequestResetPasswordResponse struct {
|
||||
Message string `json:"message" example:"Password reset code sent to your email"`
|
||||
Success bool `json:"success" example:"true"`
|
||||
}
|
||||
|
||||
// VerifyOTPResponse represents the response for OTP verification
|
||||
type VerifyOTPResponse struct {
|
||||
Message string `json:"message" example:"OTP verified successfully"`
|
||||
Token string `json:"token" example:"reset_token_here"`
|
||||
Success bool `json:"success" example:"true"`
|
||||
}
|
||||
|
||||
// ResetPasswordResponse represents the response for password reset
|
||||
type ResetPasswordResponse struct {
|
||||
Message string `json:"message" example:"Password reset successfully"`
|
||||
Success bool `json:"success" example:"true"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user