You've already forked golang-base-project
* Documents all env variables and adds an example project * Adds godoc comments * Fixed package naming issue
20 lines
399 B
Go
20 lines
399 B
Go
package models
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
"time"
|
|
)
|
|
|
|
// Session holds information about user sessions and when they expire
|
|
type Session struct {
|
|
gorm.Model
|
|
Identifier string
|
|
UserID uint
|
|
ExpiresAt time.Time
|
|
}
|
|
|
|
// HasExpired is a helper function that checks if the current time is after the session expire datetime
|
|
func (s Session) HasExpired() bool {
|
|
return s.ExpiresAt.Before(time.Now())
|
|
}
|