Fix trust center document access load + add granular error handling

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-01-29 11:34:11 +04:00
parent b8608fbec5
commit 68e93c4bc7
4 changed files with 81 additions and 18 deletions

View File

@@ -95,10 +95,18 @@ func (r *documentResolver) IsUserAuthorized(ctx context.Context, obj *types.Docu
obj.ID,
)
if err != nil {
// FIXME check for not found and return without error in this case
// r.logger.ErrorCtx(ctx, "cannot check document access", log.Error(err))
// return false, gqlutils.Internal(ctx)
return false, nil
if errors.Is(err, trust.ErrMembershipNotFound) {
return false, nil
}
if errors.Is(err, trust.ErrMembershipInactive) {
return false, nil
}
if errors.Is(err, trust.ErrDocumentAccessNotFound) {
return false, nil
}
r.logger.ErrorCtx(ctx, "cannot check document access", log.Error(err))
return false, gqlutils.Internal(ctx)
}
return documentAccess.Status == coredata.TrustCenterDocumentAccessStatusGranted, nil
@@ -820,10 +828,18 @@ func (r *reportResolver) IsUserAuthorized(ctx context.Context, obj *types.Report
obj.ID,
)
if err != nil {
// FIXME check for not found and return without error in this case
// r.logger.ErrorCtx(ctx, "cannot check report access", log.Error(err))
// return false, gqlutils.Internal(ctx)
return false, nil
if errors.Is(err, trust.ErrMembershipNotFound) {
return false, nil
}
if errors.Is(err, trust.ErrMembershipInactive) {
return false, nil
}
if errors.Is(err, trust.ErrDocumentAccessNotFound) {
return false, nil
}
r.logger.ErrorCtx(ctx, "cannot check report access", log.Error(err))
return false, gqlutils.Internal(ctx)
}
return reportAccess.Status == coredata.TrustCenterDocumentAccessStatusGranted, nil
@@ -1028,10 +1044,18 @@ func (r *trustCenterFileResolver) IsUserAuthorized(ctx context.Context, obj *typ
obj.ID,
)
if err != nil {
// FIXME check for not found and return without error in this case
// r.logger.ErrorCtx(ctx, "cannot check trust center file access", log.Error(err))
// return false, gqlutils.Internal(ctx)
return false, nil
if errors.Is(err, trust.ErrMembershipNotFound) {
return false, nil
}
if errors.Is(err, trust.ErrMembershipInactive) {
return false, nil
}
if errors.Is(err, trust.ErrDocumentAccessNotFound) {
return false, nil
}
r.logger.ErrorCtx(ctx, "cannot check trust center file access", log.Error(err))
return false, gqlutils.Internal(ctx)
}
return fileAccess.Status == coredata.TrustCenterDocumentAccessStatusGranted, nil