Exemple #1
0
func (s *Service) GetSessionInfo(sessionId string) (si SessionInformation, err error) {
	SessionQuery := bson.M{"sessionid": sessionId}
	db := s.DB.Copy()
	defer db.Close()
	err = db.FindOne("sessions", SessionQuery, &si)
	return si, err
}
Exemple #2
0
func (s *Service) RemoveAllSession() int {
	db := s.DB.Copy()
	defer db.Close()
	removed, err := s.DB.RemoveCollection("sessions", bson.M{"lastupdatedtime": bson.M{"$lt": time.Now()}})
	if err != nil {
		log.Fatal(err)
	}
	return removed
}
Exemple #3
0
func (s *Service) UpsertSession(sessionId string) {
	si := SessionInformation{}
	si.LastUpdatedTime = time.Now()
	si.SessionId = sessionId
	db := s.DB.Copy()
	defer db.Close()
	err := db.UpsertSession("sessions", bson.M{"sessionid": sessionId}, si)
	if err != nil {
		log.Fatal(err)
	}
}
Exemple #4
0
func userExist(f *fishhub.Service, email string) bool {
	db := f.DB.Copy()
	defer db.Close()
	ui := UserProfile{}
	query := bson.M{"email": email}
	err := db.FindOne("users", query, &ui)
	if err == mgo.ErrNotFound {
		return false
	} else {
		return true
	}
	return false
}