mirror of
https://github.com/aunefyren/wrapperr
synced 2024-12-13 21:02:28 +00:00
21 lines
398 B
Go
21 lines
398 B
Go
|
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
|
||
|
}
|