handler

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Health

func Health(c *gin.Context)

Health endpoint for health checks @Summary Health Check @Description Health check endpoint to verify service status including Redis connection @Tags System @Accept json @Produce json @Success 200 {object} HealthResponse "Service is healthy" @Failure 503 {object} HealthResponse "Service is unhealthy" @Router /health [get]

func HealthWithRedis

func HealthWithRedis(redisClient *redis.Client) gin.HandlerFunc

HealthWithRedis creates a health check handler that includes Redis status

Types

type AdminHandler

type AdminHandler struct {
	// contains filtered or unexported fields
}

func NewAdminHandlerDI

func NewAdminHandlerDI() *AdminHandler

func (*AdminHandler) ActivateUser

func (h *AdminHandler) ActivateUser(c *gin.Context)

ActivateUser activates a user account (Django admin equivalent) @Summary Activate User @Description Activate a user account (admin only) @Tags Admin @Accept json @Produce json @Security Bearer @Param id path string true "User ID" @Success 200 {object} dto.AdminActionResponse "User activated successfully" @Failure 400 {object} dto.AuthErrorResponse "Invalid user ID" @Failure 401 {object} dto.AuthErrorResponse "Unauthorized - invalid or missing token" @Failure 403 {object} dto.AuthErrorResponse "Forbidden - admin access required" @Failure 404 {object} dto.AuthErrorResponse "User not found" @Failure 500 {object} dto.AuthErrorResponse "Internal server error" @Router /admin/users/{id}/activate [post]

func (*AdminHandler) DeactivateUser

func (h *AdminHandler) DeactivateUser(c *gin.Context)

DeactivateUser deactivates a user account (Django admin equivalent) @Summary Deactivate User @Description Deactivate a user account (admin only) @Tags Admin @Accept json @Produce json @Security Bearer @Param id path string true "User ID" @Success 200 {object} dto.AdminActionResponse "User deactivated successfully" @Failure 400 {object} dto.AuthErrorResponse "Invalid user ID" @Failure 401 {object} dto.AuthErrorResponse "Unauthorized - invalid or missing token" @Failure 403 {object} dto.AuthErrorResponse "Forbidden - admin access required" @Failure 404 {object} dto.AuthErrorResponse "User not found" @Failure 500 {object} dto.AuthErrorResponse "Internal server error" @Router /admin/users/{id}/deactivate [post]

func (*AdminHandler) ForceVerifyUser

func (h *AdminHandler) ForceVerifyUser(c *gin.Context)

ForceVerifyUser forces verification of a user (Django admin equivalent) @Summary Force Verify User @Description Force verify a user account without OTP (admin only) @Tags Admin @Accept json @Produce json @Security Bearer @Param id path string true "User ID" @Success 200 {object} dto.AdminActionResponse "User verified successfully" @Failure 400 {object} dto.AuthErrorResponse "Invalid user ID" @Failure 401 {object} dto.AuthErrorResponse "Unauthorized - invalid or missing token" @Failure 403 {object} dto.AuthErrorResponse "Forbidden - admin access required" @Failure 404 {object} dto.AuthErrorResponse "User not found" @Failure 500 {object} dto.AuthErrorResponse "Internal server error" @Router /admin/users/{id}/force-verify [post]

func (*AdminHandler) GetUserStats

func (h *AdminHandler) GetUserStats(c *gin.Context)

GetUserStats returns user statistics (Django admin equivalent) @Summary Get User Statistics @Description Get comprehensive user statistics for admin dashboard @Tags Admin @Accept json @Produce json @Security Bearer @Success 200 {object} dto.UserStatsResponse "User statistics retrieved successfully" @Failure 401 {object} dto.AuthErrorResponse "Unauthorized - invalid or missing token" @Failure 403 {object} dto.AuthErrorResponse "Forbidden - admin access required" @Failure 500 {object} dto.AuthErrorResponse "Internal server error" @Router /admin/stats [get]

func (*AdminHandler) SearchUsers

func (h *AdminHandler) SearchUsers(c *gin.Context)

SearchUsers searches for users by query (Django admin equivalent) @Summary Search Users @Description Search for users by email, username, first name, or last name @Tags Admin @Accept json @Produce json @Security Bearer @Param q query string true "Search query (email, username, first name, or last name)" @Param page query int false "Page number for pagination" default(1) @Param limit query int false "Number of users per page" default(20) @Success 200 {object} dto.GetUsersResponse "Users found successfully" @Failure 400 {object} dto.AuthErrorResponse "Search query is required" @Failure 401 {object} dto.AuthErrorResponse "Unauthorized - invalid or missing token" @Failure 403 {object} dto.AuthErrorResponse "Forbidden - admin access required" @Failure 500 {object} dto.AuthErrorResponse "Internal server error" @Router /admin/users/search [get]

func (*AdminHandler) SendBulkEmail

func (h *AdminHandler) SendBulkEmail(c *gin.Context)

SendBulkEmail sends email to multiple users (Django equivalent) @Summary Send Bulk Email @Description Send email to multiple users at once (admin only) @Tags Admin @Accept json @Produce json @Security Bearer @Param request body dto.BulkEmailRequest true "Bulk email details" @Success 200 {object} dto.AdminActionResponse "Emails sent successfully" @Failure 400 {object} dto.AuthErrorResponse "Invalid request format" @Failure 401 {object} dto.AuthErrorResponse "Unauthorized - invalid or missing token" @Failure 403 {object} dto.AuthErrorResponse "Forbidden - admin access required" @Failure 500 {object} dto.AuthErrorResponse "Internal server error" @Router /admin/bulk-email [post]

type AuthHandler

type AuthHandler struct {
	// contains filtered or unexported fields
}

func NewAuthHandlerDI

func NewAuthHandlerDI() *AuthHandler

NewAuthHandlerDI creates a new AuthHandler using DI container.

func (*AuthHandler) ChangePassword

func (h *AuthHandler) ChangePassword(c *gin.Context)

ChangePassword handles password change (Django's ChangePasswordView equivalent) @Summary Change Password @Description Change user password with current password verification @Tags Authentication @Accept json @Produce json @Security Bearer @Param request body dto.ChangePasswordRequest true "Password change details" @Success 200 {object} dto.ChangePasswordResponse "Password changed successfully" @Failure 400 {object} dto.ChangePasswordResponse "Invalid request format" @Failure 401 {object} dto.ChangePasswordResponse "Unauthorized or invalid current password" @Failure 404 {object} dto.ChangePasswordResponse "User not found" @Failure 500 {object} dto.ChangePasswordResponse "Internal server error" @Router /auth/change-password [post]

func (*AuthHandler) DeleteAccount

func (h *AuthHandler) DeleteAccount(c *gin.Context)

DeleteAccount handles account deletion (Django's delete_account equivalent) @Summary Delete User Account @Description Permanently delete the authenticated user's account @Tags Authentication @Accept json @Produce json @Security Bearer @Success 200 {object} dto.DeleteAccountResponse "Account deleted successfully" @Failure 401 {object} dto.AuthErrorResponse "Unauthorized - invalid or missing token" @Failure 404 {object} dto.AuthErrorResponse "User not found" @Failure 500 {object} dto.AuthErrorResponse "Internal server error" @Router /auth/delete-account [delete]

func (*AuthHandler) ResendOTP

func (h *AuthHandler) ResendOTP(c *gin.Context)

ResendOTP handles OTP resend (Django's ResendOTPAPIView equivalent) @Summary Resend OTP @Description Resend verification OTP to user's email @Tags Authentication @Accept json @Produce json @Param id path string true "User ID" @Success 200 {object} dto.ResendOTPResponse "OTP sent successfully" @Failure 400 {object} dto.AuthErrorResponse "Invalid user ID" @Failure 404 {object} dto.AuthErrorResponse "User not found" @Failure 429 {object} dto.AuthErrorResponse "Too many requests - rate limited" @Failure 500 {object} dto.AuthErrorResponse "Internal server error" @Router /auth/resend-otp/{id} [post]

func (*AuthHandler) UserLogin

func (h *AuthHandler) UserLogin(c *gin.Context)

UserLogin handles user login (Django's user_login equivalent) @Summary User Login @Description Authenticate user and return JWT tokens @Tags Authentication @Accept json @Produce json @Param request body dto.LoginRequest true "Login credentials" @Success 200 {object} dto.LoginResponse "Login successful with JWT tokens" @Failure 400 {object} dto.LoginResponse "Invalid request format" @Failure 401 {object} dto.LoginResponse "Invalid credentials" @Failure 403 {object} dto.LoginResponse "Account not verified or inactive" @Failure 500 {object} dto.LoginResponse "Internal server error" @Router /auth/login [post]

func (*AuthHandler) UserLogout

func (h *AuthHandler) UserLogout(c *gin.Context)

UserLogout handles user logout (Django's user_logout equivalent) @Summary User Logout @Description Log out user and invalidate JWT tokens @Tags Authentication @Accept json @Produce json @Security Bearer @Success 200 {object} dto.LogoutResponse "Logout successful" @Failure 401 {object} dto.ErrorResponse "Unauthorized - invalid or missing token" @Failure 500 {object} dto.ErrorResponse "Internal server error" @Router /auth/logout [post]

func (*AuthHandler) UserRegister

func (h *AuthHandler) UserRegister(c *gin.Context)

UserRegister handles user registration (Django's user_register equivalent) @Summary User Registration @Description Register a new user account with email verification @Tags Authentication @Accept json @Produce json @Param request body dto.RegistrationRequest true "Registration details" @Success 201 {object} dto.RegistrationResponse "User registered successfully, OTP sent to email" @Failure 400 {object} dto.RegistrationResponse "Invalid input or validation error" @Failure 409 {object} dto.RegistrationResponse "User already exists" @Failure 500 {object} dto.RegistrationResponse "Internal server error" @Router /auth/register [post]

func (*AuthHandler) VerifyOTP

func (h *AuthHandler) VerifyOTP(c *gin.Context)

VerifyOTP handles OTP verification (Django's verify_otp equivalent) @Summary Verify OTP @Description Verify email OTP to activate user account @Tags Authentication @Accept json @Produce json @Param request body dto.VerifyOTPRequest true "OTP verification details" @Success 200 {object} dto.VerifyOTPResponse "OTP verified successfully, account activated" @Failure 400 {object} dto.VerifyOTPResponse "Invalid request format" @Failure 401 {object} dto.VerifyOTPResponse "Invalid or expired OTP" @Failure 404 {object} dto.VerifyOTPResponse "User not found" @Failure 500 {object} dto.VerifyOTPResponse "Internal server error" @Router /auth/verify-otp [post]

type HealthResponse

type HealthResponse struct {
	Status string                 `json:"status"`
	Time   string                 `json:"time"`
	Checks map[string]interface{} `json:"checks"`
}

HealthResponse represents the health check response

type PasswordResetHandler

type PasswordResetHandler struct {
	// contains filtered or unexported fields
}

PasswordResetHandler manages password reset request and confirmation endpoints.

func NewPasswordResetHandlerDI

func NewPasswordResetHandlerDI(publicHost string) *PasswordResetHandler

func (*PasswordResetHandler) ConfirmPasswordReset

func (h *PasswordResetHandler) ConfirmPasswordReset(c *gin.Context)

ConfirmPasswordReset handles verifying token and setting a new password. @Summary Confirm Password Reset @Description Validate a password reset token and set a new password. Token is single-use and expires after TTL. @Tags Authentication @Accept json @Produce json @Param request body dto.PasswordResetConfirmRequest true "Token and new password" @Success 200 {object} dto.PasswordResetConfirmResponse "Password has been reset successfully" @Failure 400 {object} dto.PasswordResetConfirmResponse "Invalid or expired token, or invalid payload" @Router /auth/password-reset/confirm [post]

func (*PasswordResetHandler) RequestPasswordReset

func (h *PasswordResetHandler) RequestPasswordReset(c *gin.Context)

RequestPasswordReset handles generating a reset token and emailing a link. @Summary Request Password Reset @Description Generate a password reset token and send reset link to email. Always returns 200 to prevent user enumeration. @Tags Authentication @Accept json @Produce json @Param request body dto.PasswordResetRequest true "Email address to reset" @Success 200 {object} dto.PasswordResetResponse "If that email exists, a reset link has been sent." @Failure 400 {object} dto.PasswordResetResponse "Invalid request payload" @Router /auth/password-reset/request [post]

type UserHandler

type UserHandler struct {
	// contains filtered or unexported fields
}

func NewUserHandlerDI

func NewUserHandlerDI() *UserHandler

NewUserHandlerDI creates a new UserHandler using DI container.

func (*UserHandler) GetAllUsers

func (h *UserHandler) GetAllUsers(c *gin.Context)

GetAllUsers returns all users (admin only) @Summary Get All Users @Description Retrieve all users in the system (admin access required) @Tags Users @Accept json @Produce json @Security Bearer @Param page query int false "Page number for pagination" default(1) @Param limit query int false "Number of users per page" default(20) @Success 200 {object} dto.GetUsersResponse "Users retrieved successfully" @Failure 401 {object} dto.AuthErrorResponse "Unauthorized - invalid or missing token" @Failure 403 {object} dto.AuthErrorResponse "Forbidden - admin access required" @Failure 500 {object} dto.AuthErrorResponse "Internal server error" @Router /user/admin/users [get]

func (*UserHandler) GetUnverifiedUsers

func (h *UserHandler) GetUnverifiedUsers(c *gin.Context)

GetUnverifiedUsers returns all unverified users (admin only) @Summary Get Unverified Users @Description Retrieve all unverified users (admin access required) @Tags Users @Accept json @Produce json @Security Bearer @Success 200 {object} dto.GetUsersResponse "Unverified users retrieved successfully" @Failure 401 {object} dto.AuthErrorResponse "Unauthorized - invalid or missing token" @Failure 403 {object} dto.AuthErrorResponse "Forbidden - admin access required" @Failure 500 {object} dto.AuthErrorResponse "Internal server error" @Router /user/admin/unverified [get]

func (*UserHandler) GetUserByID

func (h *UserHandler) GetUserByID(c *gin.Context)

GetUserByID returns a specific user by ID (admin only) @Summary Get User by ID @Description Retrieve a specific user by their ID (admin access required) @Tags Users @Accept json @Produce json @Security Bearer @Param id path string true "User ID" @Success 200 {object} dto.UserProfileResponse "User retrieved successfully" @Failure 400 {object} dto.AuthErrorResponse "Invalid user ID" @Failure 401 {object} dto.AuthErrorResponse "Unauthorized - invalid or missing token" @Failure 403 {object} dto.AuthErrorResponse "Forbidden - admin access required" @Failure 404 {object} dto.AuthErrorResponse "User not found" @Failure 500 {object} dto.AuthErrorResponse "Internal server error" @Router /user/admin/{id} [get]

func (*UserHandler) GetUserProfile

func (h *UserHandler) GetUserProfile(c *gin.Context)

GetUserProfile gets current user's profile (authenticated user) @Summary Get User Profile @Description Get the profile information of the authenticated user @Tags Users @Accept json @Produce json @Security Bearer @Success 200 {object} dto.UserProfileResponse "User profile retrieved successfully" @Failure 401 {object} dto.AuthErrorResponse "Unauthorized - invalid or missing token" @Failure 404 {object} dto.AuthErrorResponse "User not found" @Failure 500 {object} dto.AuthErrorResponse "Internal server error" @Router /user/profile [get]

func (*UserHandler) GetVerifiedUsers

func (h *UserHandler) GetVerifiedUsers(c *gin.Context)

GetVerifiedUsers returns all verified users (admin only) @Summary Get Verified Users @Description Retrieve all verified users (admin access required) @Tags Users @Accept json @Produce json @Security Bearer @Success 200 {object} dto.GetUsersResponse "Verified users retrieved successfully" @Failure 401 {object} dto.AuthErrorResponse "Unauthorized - invalid or missing token" @Failure 403 {object} dto.AuthErrorResponse "Forbidden - admin access required" @Failure 500 {object} dto.AuthErrorResponse "Internal server error" @Router /user/admin/verified [get]

func (*UserHandler) UpdateUserProfile

func (h *UserHandler) UpdateUserProfile(c *gin.Context)

UpdateUserProfile updates current user's profile @Summary Update User Profile @Description Update the authenticated user's profile information @Tags Users @Accept json @Produce json @Security Bearer @Param request body dto.UpdateUserRequest true "Profile update details" @Success 200 {object} dto.UserProfileResponse "Profile updated successfully" @Failure 400 {object} dto.AuthErrorResponse "Invalid request format" @Failure 401 {object} dto.AuthErrorResponse "Unauthorized - invalid or missing token" @Failure 404 {object} dto.AuthErrorResponse "User not found" @Failure 500 {object} dto.AuthErrorResponse "Internal server error" @Router /user/profile [put]

func (*UserHandler) UploadProfileImage

func (h *UserHandler) UploadProfileImage(c *gin.Context)

UploadProfileImage handles authenticated profile image upload @Summary Upload/Update Profile Image @Description Upload or update the authenticated user's profile image @Tags Users @Accept mpfd @Produce json @Security Bearer @Param image formData file true "Profile image file (png, jpg, jpeg, webp, gif)" @Success 200 {object} dto.UserProfileResponse "Profile image updated" @Failure 400 {object} dto.AuthErrorResponse "Invalid request or file" @Failure 401 {object} dto.AuthErrorResponse "Unauthorized" @Failure 500 {object} dto.AuthErrorResponse "Internal server error" @Router /user/profile/image [post]

Jump to

Keyboard shortcuts

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