satellite/console: store partner id on api key and project creation (#2743)
* init * remove commented code * add test * remove unnecessary code * add error log
This commit is contained in:
parent
3e41767f22
commit
878a3c802b
@ -343,6 +343,7 @@ func TestGrapqhlMutation(t *testing.T) {
|
||||
|
||||
project, err := service.GetProject(authCtx, *pID)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, rootUser.PartnerID, project.PartnerID)
|
||||
|
||||
t.Run("Update project description mutation", func(t *testing.T) {
|
||||
query := fmt.Sprintf(
|
||||
|
@ -717,9 +717,11 @@ func (s *Service) CreateProject(ctx context.Context, projectInfo ProjectInfo) (p
|
||||
Description: projectInfo.Description,
|
||||
Name: projectInfo.Name,
|
||||
OwnerID: auth.User.ID,
|
||||
PartnerID: auth.User.PartnerID,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
s.log.Error("internal error", zap.Error(err))
|
||||
return errs.New(internalErrMsg)
|
||||
}
|
||||
|
||||
@ -947,15 +949,7 @@ func (s *Service) CreateAPIKey(ctx context.Context, projectID uuid.UUID, name st
|
||||
Name: name,
|
||||
ProjectID: projectID,
|
||||
Secret: secret,
|
||||
}
|
||||
|
||||
user, err := s.GetUser(ctx, auth.User.ID)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
// If the user has a partnerID set it in the apikey for value attribution
|
||||
if !user.PartnerID.IsZero() {
|
||||
apikey.PartnerID = user.PartnerID
|
||||
PartnerID: auth.User.PartnerID,
|
||||
}
|
||||
|
||||
info, err := s.store.APIKeys().Create(ctx, key.Head(), apikey)
|
||||
|
@ -134,6 +134,14 @@ func projectFromDBX(ctx context.Context, project *dbx.Project) (_ *console.Proje
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var partnerID uuid.UUID
|
||||
if len(project.PartnerId) > 0 {
|
||||
partnerID, err = bytesToUUID(project.PartnerId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
ownerID, err := bytesToUUID(project.OwnerId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -143,6 +151,7 @@ func projectFromDBX(ctx context.Context, project *dbx.Project) (_ *console.Proje
|
||||
ID: id,
|
||||
Name: project.Name,
|
||||
Description: project.Description,
|
||||
PartnerID: partnerID,
|
||||
OwnerID: ownerID,
|
||||
CreatedAt: project.CreatedAt,
|
||||
}, nil
|
||||
|
Loading…
Reference in New Issue
Block a user