feat: adding/removing users from list now works by email

This commit is contained in:
2026-08-21 20:51:23 +02:00
parent eb45deda18
commit 3c5c8a7fe7
5 changed files with 43 additions and 11 deletions
+1 -5
View File
@@ -78,13 +78,9 @@ func (s *ListService) AddUserToList(ctx context.Context, authUserID string, list
return ErrUserIDEmpty
}
inList, err := s.repo.IsUserInList(ctx, listID, authUserID)
if err != nil {
if err := s.userAllowedToAccessList(ctx, authUserID, listID); err != nil {
return err
}
if !inList {
return ErrUserNotInList
}
return s.repo.AddUserToList(ctx, listID, userID)
}
+5
View File
@@ -17,6 +17,7 @@ type User struct {
type UserRepository interface {
CreateUser(ctx context.Context, email string, name string, passwordHash string) (*User, error)
GetUserByEmail(ctx context.Context, email string) (*User, error)
}
type UserService struct {
@@ -45,3 +46,7 @@ func (s *UserService) CreateUser(ctx context.Context, email string, name string,
return s.repo.CreateUser(ctx, email, name, string(hash))
}
func (s *UserService) GetUserByEmail(ctx context.Context, email string) (*User, error) {
return s.repo.GetUserByEmail(ctx, email)
}