auth

package
v0.0.0-...-6098c1d Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Login

func Login(c *fiber.Ctx) error

Login - Requests an OTP for authentication This function checks if the phone number is registered. If registered, it generates and sends an OTP via Fonnte API. If the phone number is not found, it returns a 404 error.

func Logout

func Logout(c *fiber.Ctx) error

Logout - Handles user logout by validating and removing the token. This function checks if the Authorization header contains a valid Bearer token. If valid, the server instructs the client to remove the token. Note: The token itself is not stored server-side, so invalidation is handled on the client.

func Register

func Register(c *fiber.Ctx) error

Register - Handles user registration. This function accepts a JSON request containing username, full name, and phone number. It checks if the username or phone number is already taken. If the user is new, it creates both a User and a Profile in the database. The role is automatically set to "user" (cannot be changed during registration).

func VerifyOTP

func VerifyOTP(c *fiber.Ctx) error

VerifyOTP - Verifies the OTP entered by the user It checks if the OTP is valid and belongs to a registered phone number. If valid, the OTP is deleted and a JWT token is generated. If invalid or expired, an error is returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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