Skip to content

Commit

Permalink
Merge pull request #4242 from nickmango/bug/gerrit-return-url
Browse files Browse the repository at this point in the history
[#4240] Bug/Gerrit Return URL
  • Loading branch information
nickmango authored Feb 10, 2024
2 parents cf7e24d + a169c17 commit d7dcb83
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions cla-backend-go/v2/sign/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2214,7 +2214,8 @@ func (s *service) RequestIndividualSignatureGerrit(ctx context.Context, input *m
return nil, err
}

callbackURL := fmt.Sprintf("%s/v4/signed/gerit/individual/%s", s.ClaV4ApiURL, *input.UserID)
// s.ClaV4ApiURL = "https://e08f-102-219-103-105.ngrok-free.app"
callbackURL := fmt.Sprintf("%s/v4/signed/gerrit/individual/%s", s.ClaV4ApiURL, *input.UserID)

preferredEmail := ""
if user.Emails != nil && len(user.Emails) > 0 {
Expand Down Expand Up @@ -2265,6 +2266,21 @@ func (s *service) RequestIndividualSignatureGerrit(ctx context.Context, input *m
return nil, err
}

// Get gerrits by claGroupID
gerrits, err := s.gerritService.GetClaGroupGerrits(ctx, *input.ProjectID)
if err != nil {
log.WithFields(f).WithError(err).Warnf("unable to lookup gerrits by project ID: %s", *input.ProjectID)
return nil, err
}

if len(gerrits.List) == 0 {
log.WithFields(f).Warnf("no gerrits found for project ID: %s", *input.ProjectID)
return nil, errors.New("no gerrits found for project")
}

returnURL := gerrits.List[0].GerritURL
log.WithFields(f).Debugf("returnURL: %s", returnURL)

if latestSignature != nil {
log.WithFields(f).Debugf("comparing latest signature document version: %s to latest document version: %s", latestSignature.SignatureDocumentMajorVersion, latestDocument.DocumentMajorVersion)
if latestDocument.DocumentMajorVersion == latestSignature.SignatureDocumentMajorVersion {
Expand All @@ -2287,7 +2303,7 @@ func (s *service) RequestIndividualSignatureGerrit(ctx context.Context, input *m
SignatureReferenceName: latestSignature.SignatureReferenceName,
SignatureReferenceNameLower: latestSignature.SignatureReferenceNameLower,
SignedOn: latestSignature.SignedOn,
SignatureReturnURL: string(input.ReturnURL),
SignatureReturnURL: string(returnURL),
SignatureReturnURLType: input.ReturnURLType,
SignatureCallbackURL: callbackURL,
SignatureACL: []string{user.LfUsername},
Expand All @@ -2311,22 +2327,6 @@ func (s *service) RequestIndividualSignatureGerrit(ctx context.Context, input *m
}
}

// Get gerrits by claGroupID
gerrits, err := s.gerritService.GetClaGroupGerrits(ctx, *input.ProjectID)
if err != nil {
log.WithFields(f).WithError(err).Warnf("unable to lookup gerrits by project ID: %s", *input.ProjectID)
return nil, err
}

if len(gerrits.List) == 0 {
log.WithFields(f).Warnf("no gerrits found for project ID: %s", *input.ProjectID)
return nil, errors.New("no gerrits found for project")
}

returnURL := gerrits.List[0].GerritURL

log.WithFields(f).Debugf("returnURL: %s", returnURL)

// Create a new signature object
_, currentTime := utils.CurrentTime()
signatureID := uuid.Must(uuid.NewV4()).String()
Expand All @@ -2342,7 +2342,7 @@ func (s *service) RequestIndividualSignatureGerrit(ctx context.Context, input *m
SignatureReferenceID: *input.UserID,
SignatureReturnURLType: input.ReturnURLType,
SignatureProjectID: *input.ProjectID,
SignatureReturnURL: string(input.ReturnURL),
SignatureReturnURL: string(returnURL),
SignatureCallbackURL: callbackURL,
SignatureACL: []string{user.LfUsername},
SignatureDocumentMajorVersion: majorVersion,
Expand Down

0 comments on commit d7dcb83

Please sign in to comment.