web

package
v0.0.0-...-bf1a2a0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

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

func CreateToken(email string) (string, error)

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.

func Serve

func Serve(db *database.DB)

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

func DecodeToken(tokenString string) (*Claims, error)

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

type RegisterBody struct {
	Email      string `json:"email"`
	Password   string `json:"password"`
	InviteCode string `json:"inviteCode"`
}

type ReqBody

type ReqBody struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

Jump to

Keyboard shortcuts

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