2
0

auth_code.go 346 B

123456789101112131415161718192021
  1. package models
  2. import (
  3. "time"
  4. "gorm.io/gorm"
  5. )
  6. // AuthCode type that extends gorm.Model
  7. type AuthCode struct {
  8. gorm.Model
  9. Token string `gorm:"unique"`
  10. AuthorizationCode string `gorm:"unique"`
  11. Expiry *time.Time
  12. }
  13. func (a *AuthCode) IsExpired() bool {
  14. timeLeft := a.Expiry.Sub(time.Now())
  15. return timeLeft < 0
  16. }