func findUsernameFromSessionID(sessionID string) (string, error) { session, err := modelhelper.GetSession(sessionID) if err != nil { return "", err } return session.Username, nil }
func getSession(r *http.Request) (*models.Session, error) { cookie, err := r.Cookie("clientId") if err != nil { return "", ErrClientIdNotFound } if cookie.Value == "" { return "", ErrCookieValueNotFound } session, err := modelhelper.GetSession(cookie.Value) if err != nil { return "", ErrSessionNotFound } return session, nil }
func (s *SessionCache) ById(id string) (*mongomodels.Session, error) { data, err := s.session.Get(id) if err != nil && err != cache.ErrNotFound { return nil, err } if err == nil { ses, ok := data.(*mongomodels.Session) if ok { return ses, nil } } session, err := modelhelper.GetSession(id) if err != nil { return nil, err } if err := s.SetToCache(session); err != nil { return nil, err } return session, nil }