summaryrefslogtreecommitdiff
path: root/nexus/models/session.go
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-03-29 22:52:46 +0530
committerBobby <[email protected]>2026-03-29 22:52:46 +0530
commit9eb9b7f4bd552a641235764f66483e1f940fcfd9 (patch)
treeda520b923b5e6758d5457b6233dd6671fc640914 /nexus/models/session.go
parent65a143a0871c35989b7c7ea6723d39a0585c089e (diff)
downloadechoes-of-vaelun-main.tar.xz
echoes-of-vaelun-main.zip
feat: nexus account manager scaffold with auth, characters, realmsHEADmain
Diffstat (limited to 'nexus/models/session.go')
-rw-r--r--nexus/models/session.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/nexus/models/session.go b/nexus/models/session.go
new file mode 100644
index 0000000..0adbba2
--- /dev/null
+++ b/nexus/models/session.go
@@ -0,0 +1,36 @@
+package models
+
+import (
+ "time"
+
+ "github.com/google/uuid"
+ "gorm.io/gorm"
+)
+
+type Session struct {
+ gorm.Model
+ ID uuid.UUID `gorm:"type:uuid;primaryKey"`
+ AccountID uuid.UUID `gorm:"type:uuid;not null;index"`
+ AuthToken string `gorm:"uniqueIndex;not null"`
+ RefreshToken string `gorm:"uniqueIndex;not null"`
+ AuthExpiry time.Time `gorm:"not null"`
+ RefreshExpiry time.Time `gorm:"not null"`
+ IPAddress string
+ UserAgent string
+ Account Account `gorm:"foreignKey:AccountID"`
+}
+
+func (self *Session) BeforeCreate(tx *gorm.DB) error {
+ if self.ID == uuid.Nil {
+ self.ID = uuid.New()
+ }
+ return nil
+}
+
+func (self *Session) IsAuthExpired() bool {
+ return time.Now().After(self.AuthExpiry)
+}
+
+func (self *Session) IsRefreshExpired() bool {
+ return time.Now().After(self.RefreshExpiry)
+}