package models import ( "errors" "time" ) // Different types of error returned by the VerifyToken function var ( ErrInvalidToken = errors.New("token is invalid") ErrExpiredToken = errors.New("token has expired") ) // Valid checks if the token payload is valid or not func (payload *Payload) Valid() error { if time.Now().After(payload.ExpiredAt) { return ErrExpiredToken } return nil }