Skip to content

Commit

Permalink
FIX: Should get memberships by user id
Browse files Browse the repository at this point in the history
  • Loading branch information
auggod committed Apr 14, 2022
1 parent f940c63 commit 0d28816
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (s *Server) GetUserMembership(ctx context.Context, user *pbUser.UserRequest
// it should not be possible to have two active memberships at the same time
err := s.db.NewSelect().
Model(&memberships).
Where("id = ?", user.Id).
Where("user_id = ?", user.Id).
Order("created_at DESC").
Limit(1).
Scan(ctx)
Expand All @@ -24,6 +24,10 @@ func (s *Server) GetUserMembership(ctx context.Context, user *pbUser.UserRequest
return nil, err
}

if len(memberships) == 0 {
return &result, nil
}

membership := memberships[0]

result.Id = membership.ID.String()
Expand Down

0 comments on commit 0d28816

Please sign in to comment.