services

package
v0.0.0-...-6778cbe Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClaimOption

type ClaimOption func(claims jwt.MapClaims)

func AddTokenExpiredAt

func AddTokenExpiredAt(deadline time.Time) ClaimOption

func AddTokenPayload

func AddTokenPayload(key string, value string) ClaimOption

type ClaimValidator

type ClaimValidator func(claims jwt.MapClaims) error

type JwtService

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

func NewJwtService

func NewJwtService(cfg *config.Config, db *database.Database) *JwtService

func (*JwtService) AdminValidator

func (s *JwtService) AdminValidator(out *ent.Admin) ClaimValidator

func (*JwtService) GenerateToken

func (s *JwtService) GenerateToken(opt ClaimOption, opts ...ClaimOption) (string, error)

GenerateToken generates a new JWT token for the given user ID.

func (*JwtService) ProtectAdmin

func (s *JwtService) ProtectAdmin() fiber.Handler

func (*JwtService) ValidateToken

func (s *JwtService) ValidateToken(tokenString string, opts ...ClaimValidator) (jwt.MapClaims, error)

ValidateToken validates the provided JWT token and returns the user ID if valid.

type PasswordService

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

func NewPasswordService

func NewPasswordService(cfg *config.Config) *PasswordService

func (*PasswordService) HashPassword

func (s *PasswordService) HashPassword(password string) (string, error)

HashPassword hashes a password using bcrypt.

func (*PasswordService) VerifyPassword

func (s *PasswordService) VerifyPassword(hashedPassword, password string) error

VerifyPassword checks if a given password matches the hashed password.

Jump to

Keyboard shortcuts

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