package main import ( "crypto/rand" "encoding/hex" "time" "go.mongodb.org/mongo-driver/bson/primitive" ) type User struct { Id primitive.ObjectID `bson:"_id" json:"id,omitempty"` Username string Password []byte `json:"-"` IsAdmin bool LastLogin time.Time } type Session struct { Id primitive.ObjectID `bson:"_id" json:"id,omitempty"` Token string UserID primitive.ObjectID IP string LoggedAt time.Time ExpiresAt time.Time IsAdmin bool } type ApiKey struct { Id primitive.ObjectID `bson:"_id" json:"id,omitempty"` UserID primitive.ObjectID Key string } type Folder struct { Id primitive.ObjectID `bson:"_id" json:"id,omitempty"` Name string Icon []byte } type Bookmark struct { Id primitive.ObjectID `bson:"_id" json:"id,omitempty"` Name string Url string FolderID primitive.ObjectID Icon []byte } type Note struct { Id primitive.ObjectID `bson:"_id" json:"id,omitempty"` Name string Content string } func GenSessionToken() string { b := make([]byte, 128) if _, err := rand.Read(b); err != nil { return "" } return hex.EncodeToString(b) }