Enha: use of sql sessions
This commit is contained in:
		| @@ -6,19 +6,19 @@ import ( | ||||
|  | ||||
| // each session contains the username of the user and the time at which it expires | ||||
| type Session struct { | ||||
| 	ID uint32 | ||||
| 	ID uint32 `db:"id"` | ||||
| 	// CurrentRoom string | ||||
| 	// Expiry      time.Time | ||||
| 	UpdatedAt   time.Time | ||||
| 	Lifetime    uint32 // minutes | ||||
| 	CookieToken string | ||||
| 	Username    string // username is playerid | ||||
| 	UpdatedAt time.Time `db:"updated_at"` | ||||
| 	Lifetime  uint32    `db:"lifetime"` // minutes | ||||
| 	TokenKey  string    `db:"token_key"` | ||||
| 	Username  string    `db:"username"` // username is playerid | ||||
| } | ||||
|  | ||||
| // we'll use this method later to determine if the session has expired | ||||
| func (s Session) IsExpired() bool { | ||||
| 	return time.Now().After(s.UpdatedAt.Add(time.Minute * time.Duration(s.Lifetime))) | ||||
| 	// return s.Expiry.Before(time.Now()) | ||||
| 	// return time.Now().After(s.UpdatedAt.Add(time.Minute * time.Duration(s.Lifetime))) | ||||
| 	return false | ||||
| } | ||||
|  | ||||
| // func ListUsernames(ss map[string]*Session) []string { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder