Documentation ¶
Index ¶
- func NotFound(c *gin.Context)
- type AuthHandler
- func (a *AuthHandler) Authenticate(c *gin.Context)
- func (a *AuthHandler) ForgotPassword(c *gin.Context)
- func (a *AuthHandler) Register(c *gin.Context)
- func (a *AuthHandler) ResetPassword(c *gin.Context)
- func (a *AuthHandler) VerifyEmail(c *gin.Context)
- func (a *AuthHandler) VerifyResetOTP(c *gin.Context)
- type AuthenticateUser
- type ErrorResponse
- type EventHandler
- type FileUploadResponse
- type ForgotPasswordInput
- type InputCreateUser
- type LoginResponse
- type LoginResponseData
- type OtpVerifyInput
- type RegisterResponse
- type RegisterResponseData
- type ResetPasswordInput
- type SuccessResponse
- type UpdateAccountInformation
- type UpdateUserProfileInput
- type UserHandler
- type UserProfile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthHandler ¶
type AuthHandler struct {
// contains filtered or unexported fields
}
func NewAuthHandler ¶
func NewAuthHandler( deps *bootstrap.AppDependencies, ) *AuthHandler
func (*AuthHandler) Authenticate ¶
func (a *AuthHandler) Authenticate(c *gin.Context)
Authenticate authenticates a user and generates a JWT token.
@Summary Authenticate User @Description Authenticate a user by validating their email and password. @Tags Authentication @Accept json @Produce json @Param credentials body AuthenticateUser true "User credentials (email and password)" @Success 200 {object} LoginResponse @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /auth/login [post]
func (*AuthHandler) ForgotPassword ¶
func (a *AuthHandler) ForgotPassword(c *gin.Context)
ForgotPassword is a route handler that sends the reset otp to the user's email address.
This endpoint is used to send the otp to the user's email address by providing the email.
@Summary Sends reset OTP @Description Sends the reset OTP to the user's email address @Tags Authentication @Accept json @Produce json @Param credentials body ForgotPasswordInput true "Input (email)" @Success 200 {string} string "Returns 'success' " @Failure 400 {string} string "Returns error message" @Router /auth/forgot-password [post]
func (*AuthHandler) Register ¶
func (a *AuthHandler) Register(c *gin.Context)
Register creates a new user account.
@Summary Register a new user @Description Create a new user account with the provided information @Tags Authentication @Accept json @Produce json @Param input body InputCreateUser true "User data to create an account" @Success 201 {object} RegisterResponse @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /auth/register [post]
func (*AuthHandler) ResetPassword ¶
func (a *AuthHandler) ResetPassword(c *gin.Context)
ResetPassword is a route handler for resetting the user's password. It requires a valid JWT token and a JSON request body with new credentials.
@Summary Reset the user's password @Description Reset the user's password using a JWT token and new credentials. @Tags Authentication @Accept json @Produce json @Param reset-token path string true "JWT token for resetting the password" @Param credentials body ResetPasswordInput true "New password and password confirmation" @Success 200 {string} string "Success: Password reset" @Failure 400 {string} string "Error: Invalid input or token" @Router /auth/reset-password/confirm/{reset-token} [post]
func (*AuthHandler) VerifyEmail ¶
func (a *AuthHandler) VerifyEmail(c *gin.Context)
VerifyEmail is a route handler that verifies the user's email address.
This endpoint is used to verify the user's email address by providing the email and OTP token.
@Summary Verify email address @Description Verifies the user's email address @Tags Authentication @Accept json @Produce json @Param email path string true "User's email address" @Param otp path string true "One-time password (OTP) token" @Success 302 {string} string "Redirects to the client URL with a jwt token" @Failure 302 {string} string "Redirects to the client URL with an error code" @Router /auth/verify/{email}/{otp} [get]
func (*AuthHandler) VerifyResetOTP ¶
func (a *AuthHandler) VerifyResetOTP(c *gin.Context)
VerifyResetOTP is a route handler that verifies the user's email address.
This endpoint is used to verify the user's email address by providing the email and OTP token.
@Summary Verify email address @Description Verifies the user's email address @Tags Authentication @Accept json @Produce json @Param credentials body OtpVerifyInput true "Input (token and email)" @Success 200 {string} string "Returns 'success and JWT' " @Failure 400 {string} string "Returns error message" @Router /auth/forgot-password/verify/ [post]
type AuthenticateUser ¶
type ErrorResponse ¶
type EventHandler ¶
type EventHandler struct {
Deps *bootsreap.AppDependencies
}
func (*EventHandler) ProcessSignup ¶
func (h *EventHandler) ProcessSignup(msg *sarama.ConsumerMessage) error
type FileUploadResponse ¶
type ForgotPasswordInput ¶
type ForgotPasswordInput struct {
Email string `json:"email" binding:"required"`
}
? ForgotPasswordInput struct
type InputCreateUser ¶
type LoginResponse ¶
type LoginResponse struct { Success bool `json:"success"` Message string `json:"message"` Data LoginResponseData `json:"data"` }
LoginResponse represents the response data structure for the login API.
type LoginResponseData ¶
type LoginResponseData struct {
JWT string `json:"jwt"`
}
LoginResponseData represents the data section of the login response.
type OtpVerifyInput ¶
type RegisterResponse ¶
type RegisterResponse struct { Success bool `json:"success"` Message string `json:"message"` Data RegisterResponseData `json:"data"` }
type RegisterResponseData ¶
type ResetPasswordInput ¶
type ResetPasswordInput struct { Password string `json:"password" binding:"required"` PasswordConfirm string `json:"passwordConfirm" binding:"required"` }
? ResetPasswordInput struct
type SuccessResponse ¶
type UpdateUserProfileInput ¶
type UpdateUserProfileInput struct {
PhoneNumber string `json:"phone_number" validate:"required"`
}
type UserHandler ¶
type UserHandler struct {
// contains filtered or unexported fields
}
func NewUserHandler ¶
func NewUserHandler(deps *bootstrap.AppDependencies, ) *UserHandler
func (*UserHandler) UpdateUserProfile ¶
func (u *UserHandler) UpdateUserProfile(c *gin.Context)
UpdateUserProfile is a route handler that handles updating the user profile
This endpoint is used to update the user profile ¶
@Summary Update user profile @Description Updates some details about the user @Tags User @Accept json @Produce json @Param credentials body UpdateUserProfileInput true "update user profile" @Security BearerAuth @Success 200 {object} SuccessResponse @Failure 401 {object} ErrorResponse @Router /user [put]
func (*UserHandler) UserProfile ¶
func (u *UserHandler) UserProfile(c *gin.Context)
UserProfile is a route handler that retrieves the user profile of the authenticated user.
This endpoint is used to get the profile information of the authenticated user based on the JWT claims.
@Summary Get user profile @Description Retrieves the profile information of the authenticated user @Tags User @Accept json @Produce json @Security BearerAuth @Success 200 {object} models.User @Failure 401 {object} ErrorResponse @Router /user/profile [get]