Documentation ¶
Index ¶
- Constants
- func CheckAndCovertToDate(dateStr string) (string, error)
- func ConvertToDate(dateStr string) (*date.Date, error)
- func ConvertToDateTime(t time.Time) *datetime.DateTime
- func TimeMustParse(layout string) time.Time
- type BcryptHasher
- type CustomClaims
- type PasswordHasher
- type TokenHandler
- type TokenHandlerIntf
Constants ¶
View Source
const ( AccessTokenExpiry = 15 * time.Minute RefreshTokenExpiry = 7 * 24 * time.Hour // 7 days )
Access and Refresh Token expiry durations
Variables ¶
This section is empty.
Functions ¶
func CheckAndCovertToDate ¶
func ConvertToDate ¶
Convert a string in "YYYY-MM-DD" format to *date.Date
func TimeMustParse ¶
Types ¶
type BcryptHasher ¶
type BcryptHasher struct{}
type CustomClaims ¶
type CustomClaims struct { UserID int `json:"user_id"` jwt.RegisteredClaims }
Custom Claims structure
type PasswordHasher ¶
func NewPasswordHasher ¶
func NewPasswordHasher() PasswordHasher
type TokenHandler ¶
type TokenHandler struct {
// contains filtered or unexported fields
}
func (TokenHandler) CheckToken ¶
func (t TokenHandler) CheckToken(tokenString string) (*CustomClaims, error)
CheckToken validates the given token string
func (TokenHandler) CreateToken ¶
func (t TokenHandler) CreateToken(userID int) (accessTokenReturn string, refreshTokenReturn string, err error)
CreateToken generates an access token and a refresh token for the given userID
type TokenHandlerIntf ¶
type TokenHandlerIntf interface { CreateToken(userID int) (accessTokenReturn string, refreshTokenReturn string, err error) CheckToken(tokenString string) (*CustomClaims, error) }
func NewTokenHandler ¶
func NewTokenHandler(config config.Config) TokenHandlerIntf
Click to show internal directories.
Click to hide internal directories.