mirror of
https://github.com/aunefyren/wrapperr
synced 2024-12-13 21:02:28 +00:00
787b00aebc
Different components moved to packages which are imported. More proper and clean compared to previous implementation.
20 lines
398 B
Go
20 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
|
|
}
|