diff --git a/server/membership.go b/server/membership.go index 46cece8..1fb8005 100644 --- a/server/membership.go +++ b/server/membership.go @@ -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) @@ -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()