Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var SECRET = []byte(os.Getenv("COOKIE_SECRET"))
The secret is a generated 32-bit string used to provide a signature to our signed tokens.
Functions ¶
func CreateToken ¶
CreateToken generates a new JWT token with the provided email and a default expiration time.
Parameters:
- email: The email address to be included in the token claims.
Returns:
- string: The generated JWT token as a string.
- error: An error, if any, encountered during token generation.
Types ¶
type Claims ¶
type Claims struct { Email string `json:"email"` // Email address associated with the token. Exp int `json:"exp"` // Expiration time of the token (Unix timestamp). jwt.RegisteredClaims // Embedded struct for standard JWT claims. }
Claims represents the custom claims structure for JWT tokens.
It includes the email address and expiration time (exp) as specified in the JSON Web Token (JWT) standard, along with additional registered claims.
func DecodeToken ¶
DecodeToken decodes a JWT token and returns the custom claims if the token is valid.
Parameters:
- tokenString: The JWT token to be decoded.
Returns:
- *Claims: The custom claims decoded from the token.
- error: An error, if any, encountered during token decoding.
type RegisterBody ¶
Click to show internal directories.
Click to hide internal directories.