//Verify verifies a token and return account id.
Verify verifies a token and return account id.
// Verify verifies a token and return account id .
func (v *JWTTokenVerifier) Verify(token string) (string, error) {
	t, err := jwt.ParseWithClaims(token, &jwt.StandardClaims{}, func(t *jwt.Token) (interface{}, error) {
		return v.PublicKey, nil
	})
	if err != nil {
		return "", fmt.Errorf("cannot parse token %v", err)
	}
	if !t.Valid {
		return "", fmt.Errorf("token not valid")
	}
	clm, ok := t.Claims.(*jwt.StandardClaims)
	if !ok {
		return "", fmt.Errorf("token claim is not StandardClaims")
	}
	if err := clm.Valid(); err != nil {
		return "", fmt.Errorf("claim not valid %v", err)
	}
	return clm.Subject, nil
}
func ( v * JWTTokenVerifier ) Verify ( token string ) ( string , error ) { t , err := jwt . ParseWithClaims ( token , & jwt . StandardClaims { } , func ( t * jwt . Token ) ( interface { } , error ) { return v . PublicKey , nil } ) if err != nil { return " " , fmt . Errorf ( " " , err ) } if ! t . Valid { return " " , fmt . Errorf ( " " ) } clm , ok := t . Claims . ( * jwt . StandardClaims ) if ! ok { return " " , fmt . Errorf ( " " ) } if err := clm . Valid ( ) ; err != nil { return " " , fmt . Errorf ( " " , err ) } return clm . Subject , nil }
Verify verifies a token and return account id.
Verify verifies a token and return account id .