//Called when a user logged in to create a new session //pass the UserID (PK in the DB) and a string describing what //they are logging in to (ie: web, IRC etc) func CreateSession(userID int, component string, db gorm.DB) string { s := Session{ Key: util.RandAlphaKey(DEFAULT_KEY_SIZE), UserID: userID, Component: component, Expires: time.Now().Add(DEFAULT_EXPIRY), Revoked: false, } db.Create(&s) return s.Key }
func NewEntity(ent *Entity, usrID uint, db gorm.DB) (*Entity, error) { ent.CreatorUserID = int(usrID) ent.APIKey = util.RandAlphaKey(DEFAULT_APIKEY_SIZE) ent.LastStatString = "" return ent, db.Save(ent).Error }