2
0

pw_reset_token.go 360 B

123456789101112131415161718192021222324
  1. package models
  2. import (
  3. "time"
  4. "gorm.io/gorm"
  5. )
  6. // PWResetToken type that extends gorm.Model
  7. type PWResetToken struct {
  8. gorm.Model
  9. Email string
  10. IsValid bool
  11. Expiry *time.Time
  12. // Token is hashed like a password before storage
  13. Token string
  14. }
  15. func (p *PWResetToken) IsExpired() bool {
  16. timeLeft := p.Expiry.Sub(time.Now())
  17. return timeLeft < 0
  18. }