portal/model/login_session.go

23 lines
393 B
Go
Raw Normal View History

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
Token string `gorm:"uniqueIndex"`
Account Account
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
}