Merged in bug/eula-email (pull request #212)

fix eula issue when email not present in jwt

* bug fix
This commit is contained in:
Jay Brown
2026-02-26 21:46:00 +00:00
parent c668485e6f
commit 62b5de5722
7 changed files with 648 additions and 312 deletions
+12 -12
View File
@@ -56,7 +56,7 @@ func (s *Controllers) ListEulaVersions(ctx echo.Context, params ListEulaVersions
"page", page,
"page_size", pageSize)
return ctx.JSON(http.StatusInternalServerError, ErrorMessage{
Message: fmt.Sprintf("Failed to list EULA versions: %v", err),
Message: fmt.Sprintf("ListEulaVersions: failed to list EULA versions: %v", err),
})
}
@@ -334,7 +334,7 @@ func (s *Controllers) ListEulaAgreements(ctx echo.Context, params ListEulaAgreem
"page", page,
"page_size", pageSize)
return ctx.JSON(http.StatusInternalServerError, ErrorMessage{
Message: fmt.Sprintf("Failed to list EULA agreements: %v", err),
Message: fmt.Sprintf("ListEulaAgreements: failed to list EULA agreements: %v", err),
})
}
@@ -381,7 +381,7 @@ func (s *Controllers) GetEulaCompliance(ctx echo.Context, params GetEulaComplian
s.cfg.GetAuthLogger().Error("GetEulaCompliance: failed to initialize AWS configuration",
"error", err)
return ctx.JSON(http.StatusInternalServerError, ErrorMessage{
Message: fmt.Sprintf("Failed to initialize AWS configuration: %v", err),
Message: fmt.Sprintf("GetEulaCompliance: failed to initialize AWS configuration: %v", err),
})
}
@@ -414,12 +414,12 @@ func (s *Controllers) GetEulaCompliance(ctx echo.Context, params GetEulaComplian
if err != nil {
if errors.Is(err, eula.ErrNoCurrentVersion) {
return ctx.JSON(http.StatusNotFound, ErrorMessage{
Message: "No current EULA version configured",
Message: "GetEulaCompliance: no current EULA version configured",
})
}
if errors.Is(err, eula.ErrVersionNotFound) {
return ctx.JSON(http.StatusNotFound, ErrorMessage{
Message: "EULA version not found",
Message: "GetEulaCompliance: specified EULA version not found",
})
}
// Check if it's a Cognito error
@@ -427,13 +427,13 @@ func (s *Controllers) GetEulaCompliance(ctx echo.Context, params GetEulaComplian
s.cfg.GetAuthLogger().Error("GetEulaCompliance: Cognito error during compliance report",
"error", err)
return ctx.JSON(http.StatusBadGateway, ErrorMessage{
Message: "Failed to fetch users from Cognito: " + err.Error(),
Message: fmt.Sprintf("GetEulaCompliance: failed to fetch users from Cognito: %v", err),
})
}
s.cfg.GetAuthLogger().Error("GetEulaCompliance: failed to generate compliance report",
"error", err)
return ctx.JSON(http.StatusInternalServerError, ErrorMessage{
Message: fmt.Sprintf("Failed to generate compliance report: %v", err),
Message: fmt.Sprintf("GetEulaCompliance: failed to generate compliance report: %v", err),
})
}
@@ -470,12 +470,12 @@ func convertComplianceReportToAPI(result *eula.ComplianceReportResult) EulaCompl
for _, u := range result.Users {
user := EulaComplianceUser{
CognitoSubjectId: u.CognitoSubjectID,
CurrentEmail: openapi_types.Email(u.CurrentEmail),
CurrentEmail: u.CurrentEmail,
Agreed: u.Agreed,
}
if u.Email != nil {
user.Email = nullable.NewNullableWithValue(openapi_types.Email(*u.Email))
user.Email = nullable.NewNullableWithValue(*u.Email)
}
if u.AgreedAt != nil {
user.AgreedAt = nullable.NewNullableWithValue(*u.AgreedAt)
@@ -511,7 +511,7 @@ func convertVersionToAPI(v *repository.Eulaversion) EulaVersion {
Title: v.Title,
Content: v.Content,
CreatedAt: v.Createdat.Time,
CreatedBy: openapi_types.Email(v.Createdby),
CreatedBy: v.Createdby,
IsCurrent: v.Iscurrent,
}
@@ -524,7 +524,7 @@ func convertVersionToAPI(v *repository.Eulaversion) EulaVersion {
version.ActivatedAt = nullable.NewNullableWithValue(v.Activatedat.Time)
}
if v.Activatedby != nil {
version.ActivatedBy = nullable.NewNullableWithValue(openapi_types.Email(*v.Activatedby))
version.ActivatedBy = nullable.NewNullableWithValue(*v.Activatedby)
}
return version
@@ -540,7 +540,7 @@ func convertAgreementToAPI(a *repository.ListEulaAgreementsRow) EulaAgreement {
return EulaAgreement{
Id: openapi_types.UUID(a.ID),
CognitoSubjectId: a.Cognitosubjectid,
UserEmail: openapi_types.Email(a.Useremail),
UserEmail: a.Useremail,
EulaVersionId: openapi_types.UUID(a.Eulaversionid),
EulaVersion: a.Eulaversionstring,
AgreedAt: agreedAt,