feat: adding/removing users from list now works by email
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user