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 }
func (u *User) GetById(id interface{}) error { db := u.DB.Copy() defer db.Close() query := bson.M{"id": id} err := db.FindOne("users", query, &u) return err }
func Create(c martini.Context, sessionService *Service, r render.Render, re *http.Request, loginForm LoginForm, f *fishhub.DBService, session sessions.Session) { db := f.DB.Copy() defer db.Close() userProfile := &user.User{} query := bson.M{"userid": loginForm.UserId, "password": loginForm.Password} err := db.FindOne("users", query, userProfile) fmt.Println(query) if err != nil { r.JSON(401, map[string]interface{}{ "message": "Unauthorized error", "classification": "UnauthorizedError", }) return } session.Set("userid", userProfile.UserId) r.JSON(200, userProfile) sessionService.UpsertSession(userProfile.UserId) c.Map(userProfile) return }