2023-04-29 17:38:21 +00:00
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
|
|
|
"gorm.io/gorm"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type LoginSession struct {
|
|
|
|
gorm.Model
|
2023-04-30 06:16:32 +00:00
|
|
|
ID uint `gorm:"primaryKey"`
|
|
|
|
AccountID uint
|
|
|
|
Account Account
|
2023-05-04 08:13:00 +00:00
|
|
|
Token string `gorm:"uniqueIndex"`
|
2023-04-29 17:38:21 +00:00
|
|
|
Expiration time.Time
|
|
|
|
CreatedAt time.Time
|
|
|
|
UpdatedAt time.Time
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *LoginSession) BeforeCreate(tx *gorm.DB) (err error) {
|
|
|
|
s.Expiration = time.Now().Add(time.Hour * 24)
|
|
|
|
return
|
|
|
|
}
|