all repos

onasty @ 844e778

a one-time notes service

onasty/internal/models/tokens.go(view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package models

import (
	"errors"
	"time"

	"github.com/gofrs/uuid/v5"
)

var (
	ErrResetPasswordTokenExpired  = errors.New("reset password token expired")
	ErrResetPasswordTokenNotFound = errors.New("reset password token not found")
)

type ResetPasswordToken struct {
	UserID    uuid.UUID
	Token     string
	CreatedAt time.Time
	ExpiresAt time.Time
}

func (p ResetPasswordToken) IsExpired() bool {
	return p.ExpiresAt.Before(time.Now())
}

type VerificationToken struct {
	UserID    uuid.UUID
	Token     string
	CreatedAt time.Time
	ExpiresAt time.Time
}