fix token issue
This commit is contained in:
@@ -69,7 +69,7 @@ func Human(d time.Duration) string {
|
||||
|
||||
var jwtKey = []byte("mysecret123")
|
||||
|
||||
func DecodeJwt(tokenString *string, user *models.User) {
|
||||
func DecodeJwt(tokenString *string, user *models.User) error {
|
||||
claims := jwt.MapClaims{}
|
||||
_, err := jwt.ParseWithClaims(*tokenString, claims, func(token *jwt.Token) (interface{}, error) {
|
||||
return []byte(jwtKey), nil
|
||||
@@ -77,10 +77,11 @@ func DecodeJwt(tokenString *string, user *models.User) {
|
||||
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
user.Username = claims["username"].(string)
|
||||
return nil
|
||||
}
|
||||
|
||||
func ValidateUser(user string) error {
|
||||
|
||||
Reference in New Issue
Block a user