handlers

package
v0.0.0-...-04b7820 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NotFound

func NotFound(c *gin.Context)

NotFound returns custom 404 page

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 AuthenticateUser struct {
	Email    string `json:"email" binding:"required,email"`
	Password string `json:"password" binding:"required"`
}

type ErrorResponse

type ErrorResponse struct {
	Data    interface{} `json:"data"`
	Message string      `json:"message"`
	Success bool        `json:"success"`
}

type EventHandler

type EventHandler struct {
	Deps *bootsreap.AppDependencies
}

func (*EventHandler) ProcessSignup

func (h *EventHandler) ProcessSignup(msg *sarama.ConsumerMessage) error

type FileUploadResponse

type FileUploadResponse struct {
	Success bool        `json:"success"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

type ForgotPasswordInput

type ForgotPasswordInput struct {
	Email string `json:"email" binding:"required"`
}

? ForgotPasswordInput struct

type InputCreateUser

type InputCreateUser struct {
	Email     string `json:"email" binding:"required,email"`
	Password  string `json:"password" binding:"required"`
	FirstName string `json:"first_name" binding:"required"`
	LastName  string `json:"last_name" binding:"required"`
}

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 OtpVerifyInput struct {
	Token string `json:"token" binding:"required"`
	Email string `json:"email" binding:"required"`
}

type RegisterResponse

type RegisterResponse struct {
	Success bool                 `json:"success"`
	Message string               `json:"message"`
	Data    RegisterResponseData `json:"data"`
}

type RegisterResponseData

type RegisterResponseData struct {
	ID    string `json:"id"`
	Email string `json:"email"`
}

type ResetPasswordInput

type ResetPasswordInput struct {
	Password        string `json:"password" binding:"required"`
	PasswordConfirm string `json:"passwordConfirm" binding:"required"`
}

? ResetPasswordInput struct

type SuccessResponse

type SuccessResponse struct {
	Message int  `json:"message"`
	Success bool `json:"success"`
}

type UpdateAccountInformation

type UpdateAccountInformation struct {
	Country        string `json:"country" validate:"required"`
	Manager        string `json:"manager" validate:"required"`
	PhoneNumber    string `json:"phone_number" validate:"required,numeric"`
	CompanyWebsite string `json:"company_website" validate:"required,url"`
}

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]

type UserProfile

type UserProfile struct {
	Email     string    `json:"email"`
	Userid    string    `json:"userid"`
	Name      string    `json:"name"`
	Country   string    `json:"country"`
	Status    string    `json:"status"`
	CreatedAt time.Time `json:"created_at"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL