Fix failed to to cannot

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2025-10-29 19:28:02 +01:00
parent 2766f8e423
commit 6f2bd9c92f
39 changed files with 198 additions and 192 deletions

View File

@@ -62,7 +62,7 @@ func AcceptInvitationHandler(authSvc *authsvc.Service, authzSvc *authz.Service,
httpserver.RenderError(w, http.StatusUnauthorized, fmt.Errorf("user not found"))
},
OnTenantError: func(err error) {
panic(fmt.Errorf("failed to list tenants for user: %w", err))
panic(fmt.Errorf("cannot list tenants for user: %w", err))
},
}

View File

@@ -127,7 +127,7 @@ func ListInvitationsHandler(authSvc *authsvc.Service, authzSvc *authz.Service, a
httpserver.RenderError(w, http.StatusUnauthorized, fmt.Errorf("user not found"))
},
OnTenantError: func(err error) {
panic(fmt.Errorf("failed to list tenants for user: %w", err))
panic(fmt.Errorf("cannot list tenants for user: %w", err))
},
}
@@ -152,7 +152,7 @@ func ListInvitationsHandler(authSvc *authsvc.Service, authzSvc *authz.Service, a
invitationsPage, err := authzSvc.GetUserInvitations(ctx, authResult.User.EmailAddress, cursor, invitationFilter)
if err != nil {
panic(fmt.Errorf("failed to list invitations for user: %w", err))
panic(fmt.Errorf("cannot list invitations for user: %w", err))
}
// Build response
@@ -195,7 +195,7 @@ func ListInvitationsHandler(authSvc *authsvc.Service, authzSvc *authz.Service, a
return nil
})
if err != nil {
panic(fmt.Errorf("failed to load organization details: %w", err))
panic(fmt.Errorf("cannot load organization details: %w", err))
}
httpserver.RenderJSON(w, http.StatusOK, response)

View File

@@ -113,7 +113,7 @@ func ListOrganizationsHandler(authSvc *authsvc.Service, authzSvc *authz.Service,
httpserver.RenderError(w, http.StatusUnauthorized, fmt.Errorf("user not found"))
},
OnTenantError: func(err error) {
panic(fmt.Errorf("failed to list tenants for user: %w", err))
panic(fmt.Errorf("cannot list tenants for user: %w", err))
},
}
@@ -126,7 +126,7 @@ func ListOrganizationsHandler(authSvc *authsvc.Service, authzSvc *authz.Service,
// Get all organizations for the user (without filtering by authentication state)
organizations, err := authzSvc.GetAllUserOrganizations(ctx, authResult.User.ID)
if err != nil {
panic(fmt.Errorf("failed to list organizations for user: %w", err))
panic(fmt.Errorf("cannot list organizations for user: %w", err))
}
// Build response with authentication requirements for each organization

View File

@@ -44,8 +44,8 @@ func SAMLACSHandler(samlSvc *authsvc.SAMLService, authSvc *authsvc.Service, auth
ctx := r.Context()
if err := r.ParseForm(); err != nil {
logger.ErrorCtx(ctx, "failed to parse form", log.Error(err))
http.Error(w, "failed to parse form", http.StatusBadRequest)
logger.ErrorCtx(ctx, "cannot parse form", log.Error(err))
http.Error(w, "cannot parse form", http.StatusBadRequest)
return
}
@@ -71,14 +71,14 @@ func SAMLACSHandler(samlSvc *authsvc.SAMLService, authSvc *authsvc.Service, auth
user, err := authSvc.CreateOrGetSAMLUser(ctx, userInfo.Email, userInfo.FullName, userInfo.SAMLSubject)
if err != nil {
logger.ErrorCtx(ctx, "cannot create or get SAML user", log.Error(err), log.String("email", userInfo.Email))
http.Error(w, "failed to create user", http.StatusInternalServerError)
http.Error(w, "cannot create user", http.StatusInternalServerError)
return
}
err = authzSvc.EnsureSAMLMembership(ctx, userInfo.TenantID, user.ID, userInfo.OrganizationID, userInfo.Role)
if err != nil {
logger.ErrorCtx(ctx, "cannot ensure membership", log.Error(err), log.String("user_id", user.ID.String()), log.String("org_id", userInfo.OrganizationID.String()))
http.Error(w, "failed to create membership", http.StatusInternalServerError)
http.Error(w, "cannot create membership", http.StatusInternalServerError)
return
}
@@ -93,7 +93,7 @@ func SAMLACSHandler(samlSvc *authsvc.SAMLService, authSvc *authsvc.Service, auth
session, err = authSvc.CreateSessionForUser(ctx, user.ID, authCfg.SessionDuration)
if err != nil {
logger.ErrorCtx(ctx, "cannot create session", log.Error(err), log.String("user_id", user.ID.String()))
http.Error(w, "failed to create session", http.StatusInternalServerError)
http.Error(w, "cannot create session", http.StatusInternalServerError)
return
}
}
@@ -110,7 +110,7 @@ func SAMLACSHandler(samlSvc *authsvc.SAMLService, authSvc *authsvc.Service, auth
err = authSvc.UpdateSessionData(ctx, session.ID, session.Data)
if err != nil {
logger.ErrorCtx(ctx, "cannot update session data", log.Error(err), log.String("session_id", session.ID.String()))
http.Error(w, "failed to update session", http.StatusInternalServerError)
http.Error(w, "cannot update session", http.StatusInternalServerError)
return
}

View File

@@ -27,7 +27,7 @@ func SAMLMetadataHandler(samlSvc *authsvc.SAMLService) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
metadataXML, err := samlSvc.GenerateMetadata()
if err != nil {
http.Error(w, fmt.Sprintf("failed to generate metadata: %v", err), http.StatusInternalServerError)
http.Error(w, fmt.Sprintf("cannot generate metadata: %v", err), http.StatusInternalServerError)
return
}