Добавить сессии в Valkey и вход через Basic с Bearer-токеном

This commit is contained in:
2026-10-06 15:08:39 +03:00
parent 3c1b63ed98
commit 9890482747
23 changed files with 1047 additions and 274 deletions
-10
View File
@@ -68,16 +68,6 @@ func (s *Service) GetByID(ctx context.Context, id uuid.UUID) (User, error) {
return s.repo.GetByID(ctx, id)
}
// Exists serves the identification middleware; it is the single-id form of
// ExistingIDs so existence is answered by one code path.
func (s *Service) Exists(ctx context.Context, id uuid.UUID) (bool, error) {
found, err := s.ExistingIDs(ctx, []uuid.UUID{id})
if err != nil {
return false, err
}
return len(found) == 1, nil
}
// ExistingIDs serves the chats module when it validates member lists.
func (s *Service) ExistingIDs(ctx context.Context, ids []uuid.UUID) ([]uuid.UUID, error) {
if len(ids) == 0 {
-6
View File
@@ -44,9 +44,6 @@ func TestRegisterStoresUserWithPasswordHash(t *testing.T) {
if got != u {
t.Fatalf("GetByID = %+v, want %+v", got, u)
}
if ok, err := svc.Exists(ctx, u.ID); err != nil || !ok {
t.Fatalf("Exists = %v, %v; want true", ok, err)
}
}
func TestRegisterRejectsInvalidInputAndStoresNothing(t *testing.T) {
@@ -129,9 +126,6 @@ func TestGetByIDUnknownIsNotFound(t *testing.T) {
if !errors.Is(err, user.ErrNotFound) || apperr.KindOf(err) != apperr.KindNotFound {
t.Fatalf("err = %v, want ErrNotFound with KindNotFound", err)
}
if ok, err := svc.Exists(context.Background(), ident.New()); err != nil || ok {
t.Fatalf("Exists = %v, %v; want false, nil", ok, err)
}
}
func TestExistingIDsReturnsOnlyRegistered(t *testing.T) {