Documentation ¶
Index ¶
- type ClaimOption
- type ClaimValidator
- type JwtService
- func (s *JwtService) AdminValidator(out *ent.Admin) ClaimValidator
- func (s *JwtService) GenerateToken(opt ClaimOption, opts ...ClaimOption) (string, error)
- func (s *JwtService) ProtectAdmin() fiber.Handler
- func (s *JwtService) ValidateToken(tokenString string, opts ...ClaimValidator) (jwt.MapClaims, error)
- type PasswordService
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.
Click to show internal directories.
Click to hide internal directories.