From 0d288163b9427ed493748ac111514630b7c8f569 Mon Sep 17 00:00:00 2001 From: Augustin Godiscal Date: Thu, 14 Apr 2022 15:39:58 +0200 Subject: [PATCH] FIX: Should get memberships by user id --- server/membership.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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()