-
Notifications
You must be signed in to change notification settings - Fork 42
/
token.go
19 lines (16 loc) · 902 Bytes
/
token.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package model
import (
"database/sql"
"gorm.io/gorm"
)
const TokenScopeAdmin = "admin"
// Token can be used to authenticate instead of a user account
type Token struct {
gorm.Model
UserID uint // used by gorm
User User `gorm:"foreignKey:user_id;not null;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"` // creator of the token
Token string `json:"token" gorm:"not null"` // secret token
Expires sql.NullTime `json:"expires"` // expiration date (null if none)
Scope string `json:"scope" gorm:"not null"` // scope of the token, currently only admin
LastUse sql.NullTime `json:"last_use"` // last time the token was used
}