Documentation ¶
Index ¶
- Constants
- Variables
- func BytesDataHash(data []byte) string
- func CheckEmailSentIn3Minute(email string) bool
- func CreatQRCodeBytes(content string) ([]byte, error)
- func CreateJWTToken(claims CustomJWTClaims, salt []byte) (string, error)
- func GetPasswordHash(password string, salts ...string) string
- func GetRedisClient(addr, password string, db int) *redis.Client
- func GetReflectFieldNames(instance interface{}) map[string]int
- func GetReflectValueByField(instance interface{}, field string) (interface{}, error)
- func GinFormFileHash(file *multipart.FileHeader) (string, []byte, error)
- func ParseQRCodeBytes(data []byte) (string, error)
- func RefreshJWTToken(tokenString string, salt []byte, survivalTime time.Duration) (string, error)
- func SendPasswordResetEmail(email, authToken string) error
- func SetEmailSentTag(email string)
- func UploadDataToCloud() error
- func UploadFileToLocal(data []byte, path string) error
- type CustomJWTClaims
Constants ¶
const ResetPasswordEmailTemplate = `` /* 436-byte string literal not displayed */
Variables ¶
var ( TokenExpired = errors.New(" Token is expired") TokenNotValidYet = errors.New(" Token not active yet") TokenMalformed = errors.New(" That's not even a token") TokenInvalid = errors.New(" Couldn't handle this token:") )
Error notes
Functions ¶
func CheckEmailSentIn3Minute ¶
Check the record of sent an email for reset password to the user in 10 minute. If sent already, return true, else return false
func CreatQRCodeBytes ¶
return a qrCode bytes data
func CreateJWTToken ¶
func CreateJWTToken(claims CustomJWTClaims, salt []byte) (string, error)
Create JWT token
func GetPasswordHash ¶
get a password hash vale with salts
func GetReflectFieldNames ¶
get all field name of a struct
func GetReflectValueByField ¶
get a field value if a struct by the field name
func GinFormFileHash ¶
func GinFormFileHash(file *multipart.FileHeader) (string, []byte, error)
return the hash value of an file which recv in Gin
func ParseQRCodeBytes ¶
return qrCode real content
func RefreshJWTToken ¶
Refresh JWT token
func SendPasswordResetEmail ¶
Send an email for reset password to the user, the core content is a authentication string, that can mark user was sign in, use to update the password
func SetEmailSentTag ¶
func SetEmailSentTag(email string)
Save a tag value in redis, to mark have sent the reset password email for the user. The expire time of the data is 3 minute.
func UploadDataToCloud ¶
func UploadDataToCloud() error
todo upload file data to oss or other static file server
func UploadFileToLocal ¶
upload the file to local dir
Types ¶
type CustomJWTClaims ¶
type CustomJWTClaims struct { Id int64 `json:"user_id"` jwt.StandardClaims }
Payload, contains some custom information
func ParseJWTToken ¶
func ParseJWTToken(tokenString string, salt []byte) (*CustomJWTClaims, error)
Parse JWT token