Documentation ¶
Index ¶
- func DeleteUserById(c *fiber.Ctx) error
- func ForgotPassword(c *fiber.Ctx) error
- func GetAllAdminUsers(c *fiber.Ctx) error
- func GetAllUsers(c *fiber.Ctx) error
- func GetUserById(c *fiber.Ctx) error
- func Login(c *fiber.Ctx) error
- func Register(c *fiber.Ctx) error
- func ResetPassword(c *fiber.Ctx) error
- func SendEmailVerification(c *fiber.Ctx) error
- func UpdateUser(c *fiber.Ctx) error
- func VerifyEmail(c *fiber.Ctx) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteUserById ¶
func DeleteUserById(c *fiber.Ctx) error
DeleteUserById deletes the user based on the ID in the JWT token claims. It ensures the user is authenticated and deletes the user from the database. If unauthorized or an error occurs during deletion, an appropriate error response is returned.
func ForgotPassword ¶
func ForgotPassword(c *fiber.Ctx) error
ForgotPassword handles the request to send a password reset link to the user's email.
@param c *fiber.Ctx: The Fiber context containing the request and response details.
@returns error: - 400 Bad Request: Invalid email format or email not found in the database. - 500 Internal Server Error: Failed to create the verification token or send the password reset email. - 200 OK: Email sent successfully with a password reset link.
func GetAllAdminUsers ¶
func GetAllAdminUsers(c *fiber.Ctx) error
GetAllAdminUsers retrieves all admin users from the database. It returns a list of users who have admin privileges in the response. If there is a database error, it responds with a 500 (Internal Server Error).
func GetAllUsers ¶
func GetAllUsers(c *fiber.Ctx) error
GetAllUsers retrieves all users from the database. It returns a list of users in the response with a status of 200 (OK). If there is a database error, it responds with a 500 (Internal Server Error) and an error message.
func GetUserById ¶
func GetUserById(c *fiber.Ctx) error
GetUserById retrieves the user based on the ID in the JWT token claims. It checks if the user is authenticated and returns the user's data. If unauthorized or if the user is not found, it returns an appropriate error response.
func Login ¶
func Login(c *fiber.Ctx) error
Login handles user login requests.
@param c *fiber.Ctx: The Fiber context containing the request and response details.
@returns error: - 400 Bad Request: Invalid request body. - 401 Unauthorized: Authentication failed due to invalid email or password. - 200 OK: Login successful with a success message in JSON format.
func Register ¶
func Register(c *fiber.Ctx) error
Register handles user registration requests.
@param c *fiber.Ctx: The Fiber context containing the request and response details.
@returns error: - 400 Bad Request: Invalid request body or password hashing failure. - 409 Conflict: User already exists. - 201 Created: Registration successful with a success message in JSON format.
func ResetPassword ¶
func ResetPassword(c *fiber.Ctx) error
ResetPassword handles the request to reset a user's password using a verification token.
@param c *fiber.Ctx: The Fiber context containing the request and response details.
@returns error: - 400 Bad Request: Invalid or expired verification token, or invalid request body. - 500 Internal Server Error: Failed to hash the new password or reset the password in the database. - 200 OK: Password reset successfully.
func SendEmailVerification ¶
func SendEmailVerification(c *fiber.Ctx) error
SendEmailVerification sends an email verification link to the user.
@param c *fiber.Ctx: The Fiber context containing the request and response details.
@returns error: - 400 Bad Request: Token claims could not be parsed, or user ID is invalid. - 401 Unauthorized: Missing or invalid access token. - 404 Not Found: The user associated with the token is not found in the database. - 500 Internal Server Error: Failed to create the verification token or send the verification email. - 200 OK: Email sent successfully with a verification link.
func UpdateUser ¶
func UpdateUser(c *fiber.Ctx) error
UpdateUser handles updating the authenticated user's profile information. The function allows users to optionally update their first name, last name, email, and profile picture. It also replaces the access and refresh tokens if the email is updated, and verifies the password for security purposes.
func VerifyEmail ¶
func VerifyEmail(c *fiber.Ctx) error
VerifyEmail handles email verification requests using a token.
@param c *fiber.Ctx: The Fiber context containing the request and response details.
@returns error: - 400 Bad Request: Invalid or expired verification token. - 401 Unauthorized: Verification token has expired or user not found. - 200 OK: Email successfully verified with a success message in JSON format.
Types ¶
This section is empty.