Documentation ¶
Index ¶
- func CheckPasswordHash(password, hash string) bool
- func Decode(source, dest interface{}) error
- func GenerateToken(email, password string) (string, error)
- func GetSecretKey() []byte
- func GetSnowflakeID() string
- func HashPassword(password string) (string, error)
- func InitSnowflakeGenerator(id int64) error
- func ParseSnowflakeID(data string) (snowflake.ID, error)
- func ParseToken(tokenStr string) (string, error)
- func RefreshToken(tokenStr string, expirationTime time.Time) (string, error)
- type Claims
- type Credentials
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPasswordHash ¶
func GenerateToken ¶
GenerateToken generates a jwt token and assign a email to it's claims and return it
func GetSecretKey ¶
func GetSecretKey() []byte
func GetSnowflakeID ¶
func GetSnowflakeID() string
func HashPassword ¶
func InitSnowflakeGenerator ¶
func ParseToken ¶
ParseToken parses a jwt token and returns the email in it's claims
Types ¶
type Claims ¶
type Claims struct { Email string `json:"email"` Password string `json:"password"` jwt.StandardClaims }
Create a struct that will be encoded to a JWT. We add jwt.StandardClaims as an embedded type, to provide fields like expiry time
type Credentials ¶
type Credentials struct { Password string `json:"password" mapstructure:"password"` Email string `json:"email" mapstructure:"email"` }
Create a struct to read the username and password from the request body
Click to show internal directories.
Click to hide internal directories.