This commit is contained in:
parent
b6f12b7acf
commit
8f8ad3035a
33 changed files with 166 additions and 111 deletions
|
@ -2,21 +2,19 @@ package models
|
|||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gen"
|
||||
)
|
||||
|
||||
// AccessToken maps a unique token to one account.
|
||||
// Access to server resource may only happen with a valid access token.
|
||||
// Access tokens are granted by [auth-new/auth.Authenticator].
|
||||
// Each account may have multiple access tokens at any time
|
||||
type AccessToken struct {
|
||||
User User
|
||||
User User // The account the token belongs to
|
||||
UserId string
|
||||
Token string `gorm:"primarykey;type:uuid;default:gen_random_uuid()"`
|
||||
Name string // Token name will be empty if autogenerated with sucessful login
|
||||
// The token itself is a uuid value
|
||||
Token string `gorm:"primarykey;type:uuid;default:gen_random_uuid()"`
|
||||
Name string // Token name will be empty if autogenerated with sucessful login
|
||||
// Every token expires, even if set to "not expire". If set to "not expire", it just expires
|
||||
// at a point in the future this server should never reach
|
||||
ExpiresAt time.Time `gorm:"default:TIMESTAMP WITH TIME ZONE '9999-12-30 23:59:59+00'"`
|
||||
}
|
||||
|
||||
type IAccessToken interface {
|
||||
// INSERT INTO @@table (user_id, token, name, {{if expiresAt != nil}}, )
|
||||
NewToken(user *User, name string, expiresAt *time.Time) (gen.T, error)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue