Comment all new code
Some checks are pending
/ test (push) Waiting to run

This commit is contained in:
Melody Becker 2025-04-02 15:33:07 +02:00
parent b6f12b7acf
commit 8f8ad3035a
Signed by: mstar
SSH key fingerprint: SHA256:9VAo09aaVNTWKzPW7Hq2LW+ox9OdwmTSHRoD4mlz1yI
33 changed files with 166 additions and 111 deletions

View file

@ -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)
}