Beispiel #1
0
// Get implememnts the api.Storage interface.
//
// If session for requested user does not exist,
// api.ErrSessionNotFound is returned.
func (trx *TrxStorage) Get(u *api.User) (*api.Session, error) {
	trx.mu.Lock()
	trx.Trxs = append(trx.Trxs, Trx{Type: "get", Session: &api.Session{User: u}})
	trxS, ok := trx.build()[u.String()]
	trx.mu.Unlock()

	if !ok {
		return nil, api.ErrSessionNotFound
	}

	return trxS, nil
}
Beispiel #2
0
// Get implements the api.Storage interface.
func (st *Storage) Get(u *api.User) (*api.Session, error) {
	var sessions map[string]api.Session

	err := st.Cache.GetValue("auth.sessions", &sessions)
	if err == storage.ErrKeyNotFound {
		return nil, api.ErrSessionNotFound
	}
	if err != nil {
		return nil, err
	}

	session, ok := sessions[u.String()]
	if !ok {
		return nil, api.ErrSessionNotFound
	}

	return &session, nil
}