@@ -27,3 +27,6 @@ models:
|
||||
CursorKey:
|
||||
model:
|
||||
- "go.probo.inc/probo/pkg/server/gqlutils/types/cursor.CursorKeyScalar"
|
||||
EmailAddr:
|
||||
model:
|
||||
- "go.probo.inc/probo/pkg/server/gqlutils/types/mail.AddrScalar"
|
||||
|
||||
@@ -19,8 +19,9 @@ enum Role {
|
||||
USER
|
||||
}
|
||||
|
||||
scalar Datetime
|
||||
scalar CursorKey
|
||||
scalar Datetime
|
||||
scalar EmailAddr
|
||||
|
||||
interface Node {
|
||||
id: ID!
|
||||
@@ -46,11 +47,9 @@ type Organization implements Node {
|
||||
|
||||
enum DocumentType
|
||||
@goModel(model: "go.probo.inc/probo/pkg/coredata.DocumentType") {
|
||||
OTHER
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypeOther")
|
||||
OTHER @goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypeOther")
|
||||
ISMS @goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypeISMS")
|
||||
POLICY
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypePolicy")
|
||||
POLICY @goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypePolicy")
|
||||
PROCEDURE
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypeProcedure")
|
||||
}
|
||||
@@ -357,9 +356,7 @@ enum CountryCode
|
||||
enum VendorCategory
|
||||
@goModel(model: "go.probo.inc/probo/pkg/coredata.VendorCategory") {
|
||||
ANALYTICS
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryAnalytics"
|
||||
)
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryAnalytics")
|
||||
CLOUD_MONITORING
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryCloudMonitoring"
|
||||
@@ -389,28 +386,21 @@ enum VendorCategory
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryEmployeeManagement"
|
||||
)
|
||||
ENGINEERING
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryEngineering"
|
||||
)
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryEngineering")
|
||||
FINANCE
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryFinance"
|
||||
)
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryFinance")
|
||||
IDENTITY_PROVIDER
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryIdentityProvider"
|
||||
)
|
||||
IT @goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryIT")
|
||||
MARKETING
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryMarketing"
|
||||
)
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryMarketing")
|
||||
OFFICE_OPERATIONS
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryOfficeOperations"
|
||||
)
|
||||
OTHER
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryOther")
|
||||
OTHER @goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryOther")
|
||||
PASSWORD_MANAGEMENT
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryPasswordManagement"
|
||||
@@ -424,15 +414,10 @@ enum VendorCategory
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryProfessionalServices"
|
||||
)
|
||||
RECRUITING
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryRecruiting"
|
||||
)
|
||||
SALES
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategorySales")
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryRecruiting")
|
||||
SALES @goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategorySales")
|
||||
SECURITY
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategorySecurity"
|
||||
)
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategorySecurity")
|
||||
VERSION_CONTROL
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryVersionControl"
|
||||
@@ -542,7 +527,7 @@ type TrustCenter implements Node {
|
||||
|
||||
type TrustCenterAccess implements Node {
|
||||
id: ID!
|
||||
email: String!
|
||||
email: EmailAddr!
|
||||
name: String!
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
@@ -550,7 +535,7 @@ type TrustCenterAccess implements Node {
|
||||
|
||||
input RequestAllAccessesInput {
|
||||
trustCenterId: ID!
|
||||
email: String
|
||||
email: EmailAddr
|
||||
name: String
|
||||
}
|
||||
|
||||
@@ -573,21 +558,21 @@ input AcceptNonDisclosureAgreementInput {
|
||||
input RequestDocumentAccessInput {
|
||||
trustCenterId: ID!
|
||||
documentId: ID!
|
||||
email: String
|
||||
email: EmailAddr
|
||||
name: String
|
||||
}
|
||||
|
||||
input RequestReportAccessInput {
|
||||
trustCenterId: ID!
|
||||
reportId: ID!
|
||||
email: String
|
||||
email: EmailAddr
|
||||
name: String
|
||||
}
|
||||
|
||||
input RequestTrustCenterFileAccessInput {
|
||||
trustCenterId: ID!
|
||||
trustCenterFileId: ID!
|
||||
email: String
|
||||
email: EmailAddr
|
||||
name: String
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,12 @@ import (
|
||||
"github.com/vektah/gqlparser/v2/ast"
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/mail"
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
"go.probo.inc/probo/pkg/server/api/trust/v1/types"
|
||||
"go.probo.inc/probo/pkg/server/gqlutils/types/cursor"
|
||||
gid1 "go.probo.inc/probo/pkg/server/gqlutils/types/gid"
|
||||
mail1 "go.probo.inc/probo/pkg/server/gqlutils/types/mail"
|
||||
)
|
||||
|
||||
// region ************************** generated!.gotpl **************************
|
||||
@@ -1115,8 +1117,9 @@ enum Role {
|
||||
USER
|
||||
}
|
||||
|
||||
scalar Datetime
|
||||
scalar CursorKey
|
||||
scalar Datetime
|
||||
scalar EmailAddr
|
||||
|
||||
interface Node {
|
||||
id: ID!
|
||||
@@ -1142,11 +1145,9 @@ type Organization implements Node {
|
||||
|
||||
enum DocumentType
|
||||
@goModel(model: "go.probo.inc/probo/pkg/coredata.DocumentType") {
|
||||
OTHER
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypeOther")
|
||||
OTHER @goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypeOther")
|
||||
ISMS @goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypeISMS")
|
||||
POLICY
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypePolicy")
|
||||
POLICY @goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypePolicy")
|
||||
PROCEDURE
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypeProcedure")
|
||||
}
|
||||
@@ -1453,9 +1454,7 @@ enum CountryCode
|
||||
enum VendorCategory
|
||||
@goModel(model: "go.probo.inc/probo/pkg/coredata.VendorCategory") {
|
||||
ANALYTICS
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryAnalytics"
|
||||
)
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryAnalytics")
|
||||
CLOUD_MONITORING
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryCloudMonitoring"
|
||||
@@ -1485,28 +1484,21 @@ enum VendorCategory
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryEmployeeManagement"
|
||||
)
|
||||
ENGINEERING
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryEngineering"
|
||||
)
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryEngineering")
|
||||
FINANCE
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryFinance"
|
||||
)
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryFinance")
|
||||
IDENTITY_PROVIDER
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryIdentityProvider"
|
||||
)
|
||||
IT @goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryIT")
|
||||
MARKETING
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryMarketing"
|
||||
)
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryMarketing")
|
||||
OFFICE_OPERATIONS
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryOfficeOperations"
|
||||
)
|
||||
OTHER
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryOther")
|
||||
OTHER @goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryOther")
|
||||
PASSWORD_MANAGEMENT
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryPasswordManagement"
|
||||
@@ -1520,15 +1512,10 @@ enum VendorCategory
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryProfessionalServices"
|
||||
)
|
||||
RECRUITING
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryRecruiting"
|
||||
)
|
||||
SALES
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategorySales")
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryRecruiting")
|
||||
SALES @goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategorySales")
|
||||
SECURITY
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategorySecurity"
|
||||
)
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategorySecurity")
|
||||
VERSION_CONTROL
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryVersionControl"
|
||||
@@ -1638,7 +1625,7 @@ type TrustCenter implements Node {
|
||||
|
||||
type TrustCenterAccess implements Node {
|
||||
id: ID!
|
||||
email: String!
|
||||
email: EmailAddr!
|
||||
name: String!
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
@@ -1646,7 +1633,7 @@ type TrustCenterAccess implements Node {
|
||||
|
||||
input RequestAllAccessesInput {
|
||||
trustCenterId: ID!
|
||||
email: String
|
||||
email: EmailAddr
|
||||
name: String
|
||||
}
|
||||
|
||||
@@ -1669,21 +1656,21 @@ input AcceptNonDisclosureAgreementInput {
|
||||
input RequestDocumentAccessInput {
|
||||
trustCenterId: ID!
|
||||
documentId: ID!
|
||||
email: String
|
||||
email: EmailAddr
|
||||
name: String
|
||||
}
|
||||
|
||||
input RequestReportAccessInput {
|
||||
trustCenterId: ID!
|
||||
reportId: ID!
|
||||
email: String
|
||||
email: EmailAddr
|
||||
name: String
|
||||
}
|
||||
|
||||
input RequestTrustCenterFileAccessInput {
|
||||
trustCenterId: ID!
|
||||
trustCenterFileId: ID!
|
||||
email: String
|
||||
email: EmailAddr
|
||||
name: String
|
||||
}
|
||||
|
||||
@@ -4584,7 +4571,7 @@ func (ec *executionContext) _TrustCenterAccess_email(ctx context.Context, field
|
||||
return obj.Email, nil
|
||||
},
|
||||
nil,
|
||||
ec.marshalNString2string,
|
||||
ec.marshalNEmailAddr2goᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr,
|
||||
true,
|
||||
true,
|
||||
)
|
||||
@@ -4597,7 +4584,7 @@ func (ec *executionContext) fieldContext_TrustCenterAccess_email(_ context.Conte
|
||||
IsMethod: false,
|
||||
IsResolver: false,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
return nil, errors.New("field of type String does not have child fields")
|
||||
return nil, errors.New("field of type EmailAddr does not have child fields")
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
@@ -7165,7 +7152,7 @@ func (ec *executionContext) unmarshalInputRequestAllAccessesInput(ctx context.Co
|
||||
it.TrustCenterID = data
|
||||
case "email":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email"))
|
||||
data, err := ec.unmarshalOString2ᚖstring(ctx, v)
|
||||
data, err := ec.unmarshalOEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
@@ -7213,7 +7200,7 @@ func (ec *executionContext) unmarshalInputRequestDocumentAccessInput(ctx context
|
||||
it.DocumentID = data
|
||||
case "email":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email"))
|
||||
data, err := ec.unmarshalOString2ᚖstring(ctx, v)
|
||||
data, err := ec.unmarshalOEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
@@ -7261,7 +7248,7 @@ func (ec *executionContext) unmarshalInputRequestReportAccessInput(ctx context.C
|
||||
it.ReportID = data
|
||||
case "email":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email"))
|
||||
data, err := ec.unmarshalOString2ᚖstring(ctx, v)
|
||||
data, err := ec.unmarshalOEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
@@ -7309,7 +7296,7 @@ func (ec *executionContext) unmarshalInputRequestTrustCenterFileAccessInput(ctx
|
||||
it.TrustCenterFileID = data
|
||||
case "email":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email"))
|
||||
data, err := ec.unmarshalOString2ᚖstring(ctx, v)
|
||||
data, err := ec.unmarshalOEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
@@ -10647,6 +10634,22 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func (ec *executionContext) unmarshalNEmailAddr2goᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx context.Context, v any) (mail.Addr, error) {
|
||||
res, err := mail1.UnmarshalAddrScalar(v)
|
||||
return res, graphql.ErrorOnPath(ctx, err)
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalNEmailAddr2goᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx context.Context, sel ast.SelectionSet, v mail.Addr) graphql.Marshaler {
|
||||
_ = sel
|
||||
res := mail1.MarshalAddrScalar(v)
|
||||
if res == graphql.Null {
|
||||
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||
ec.Errorf(ctx, "the requested element is null which the schema does not allow")
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func (ec *executionContext) unmarshalNExportDocumentPDFInput2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋtrustᚋv1ᚋtypesᚐExportDocumentPDFInput(ctx context.Context, v any) (types.ExportDocumentPDFInput, error) {
|
||||
res, err := ec.unmarshalInputExportDocumentPDFInput(ctx, v)
|
||||
return res, graphql.ErrorOnPath(ctx, err)
|
||||
@@ -11431,6 +11434,24 @@ func (ec *executionContext) marshalOCursorKey2ᚖgoᚗproboᚗincᚋproboᚋpkg
|
||||
return res
|
||||
}
|
||||
|
||||
func (ec *executionContext) unmarshalOEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx context.Context, v any) (*mail.Addr, error) {
|
||||
if v == nil {
|
||||
return nil, nil
|
||||
}
|
||||
res, err := mail1.UnmarshalAddrScalar(v)
|
||||
return &res, graphql.ErrorOnPath(ctx, err)
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalOEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx context.Context, sel ast.SelectionSet, v *mail.Addr) graphql.Marshaler {
|
||||
if v == nil {
|
||||
return graphql.Null
|
||||
}
|
||||
_ = sel
|
||||
_ = ctx
|
||||
res := mail1.MarshalAddrScalar(*v)
|
||||
return res
|
||||
}
|
||||
|
||||
func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v any) (*int, error) {
|
||||
if v == nil {
|
||||
return nil, nil
|
||||
|
||||
@@ -21,20 +21,17 @@ import (
|
||||
"github.com/99designs/gqlgen/graphql"
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/mail"
|
||||
"go.probo.inc/probo/pkg/server/api/trust/v1/types"
|
||||
)
|
||||
|
||||
type TokenAccessData struct {
|
||||
TrustCenterID gid.GID
|
||||
Email string
|
||||
Email mail.Addr
|
||||
TenantID gid.TenantID
|
||||
Scope string
|
||||
}
|
||||
|
||||
func (t *TokenAccessData) GetEmail() string {
|
||||
return t.Email
|
||||
}
|
||||
|
||||
type ContextAccessor interface {
|
||||
UserFromContext(ctx context.Context) *coredata.User
|
||||
TokenAccessFromContext(ctx context.Context) *TokenAccessData
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/mail"
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
@@ -140,30 +141,30 @@ type RequestAccessesPayload struct {
|
||||
}
|
||||
|
||||
type RequestAllAccessesInput struct {
|
||||
TrustCenterID gid.GID `json:"trustCenterId"`
|
||||
Email *string `json:"email,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
TrustCenterID gid.GID `json:"trustCenterId"`
|
||||
Email *mail.Addr `json:"email,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
type RequestDocumentAccessInput struct {
|
||||
TrustCenterID gid.GID `json:"trustCenterId"`
|
||||
DocumentID gid.GID `json:"documentId"`
|
||||
Email *string `json:"email,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
TrustCenterID gid.GID `json:"trustCenterId"`
|
||||
DocumentID gid.GID `json:"documentId"`
|
||||
Email *mail.Addr `json:"email,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
type RequestReportAccessInput struct {
|
||||
TrustCenterID gid.GID `json:"trustCenterId"`
|
||||
ReportID gid.GID `json:"reportId"`
|
||||
Email *string `json:"email,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
TrustCenterID gid.GID `json:"trustCenterId"`
|
||||
ReportID gid.GID `json:"reportId"`
|
||||
Email *mail.Addr `json:"email,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
type RequestTrustCenterFileAccessInput struct {
|
||||
TrustCenterID gid.GID `json:"trustCenterId"`
|
||||
TrustCenterFileID gid.GID `json:"trustCenterFileId"`
|
||||
Email *string `json:"email,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
TrustCenterID gid.GID `json:"trustCenterId"`
|
||||
TrustCenterFileID gid.GID `json:"trustCenterFileId"`
|
||||
Email *mail.Addr `json:"email,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
type TrustCenter struct {
|
||||
@@ -187,7 +188,7 @@ func (this TrustCenter) GetID() gid.GID { return this.ID }
|
||||
|
||||
type TrustCenterAccess struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Email string `json:"email"`
|
||||
Email mail.Addr `json:"email"`
|
||||
Name string `json:"name"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/vektah/gqlparser/v2/gqlerror"
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/mail"
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
"go.probo.inc/probo/pkg/server/api/trust/v1/schema"
|
||||
"go.probo.inc/probo/pkg/server/api/trust/v1/types"
|
||||
@@ -82,7 +83,7 @@ func (r *documentResolver) IsUserAuthorized(ctx context.Context, obj *types.Docu
|
||||
|
||||
tokenData := TokenAccessFromContext(ctx)
|
||||
if tokenData != nil {
|
||||
documentAccess, err := privateTrustService.TrustCenterAccesses.LoadDocumentAccess(ctx, tokenData.TrustCenterID, tokenData.GetEmail(), obj.ID)
|
||||
documentAccess, err := privateTrustService.TrustCenterAccesses.LoadDocumentAccess(ctx, tokenData.TrustCenterID, tokenData.Email, obj.ID)
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
@@ -108,7 +109,7 @@ func (r *documentResolver) HasUserRequestedAccess(ctx context.Context, obj *type
|
||||
tokenData := TokenAccessFromContext(ctx)
|
||||
if tokenData != nil {
|
||||
// Try to load document access - if it exists (regardless of active status), user has requested it
|
||||
_, err := privateTrustService.TrustCenterAccesses.LoadDocumentAccess(ctx, tokenData.TrustCenterID, tokenData.GetEmail(), obj.ID)
|
||||
_, err := privateTrustService.TrustCenterAccesses.LoadDocumentAccess(ctx, tokenData.TrustCenterID, tokenData.Email, obj.ID)
|
||||
if err != nil {
|
||||
return false, nil // No access requested or error
|
||||
}
|
||||
@@ -133,8 +134,8 @@ func (r *mutationResolver) RequestAllAccesses(ctx context.Context, input types.R
|
||||
if email != nil || input.Name != nil {
|
||||
return nil, fmt.Errorf("email and name are not allowed for authenticated users")
|
||||
}
|
||||
emailValue := tokenData.GetEmail()
|
||||
email = &emailValue
|
||||
|
||||
*email = tokenData.Email
|
||||
}
|
||||
if email == nil {
|
||||
return nil, fmt.Errorf("email is required for unauthenticated users")
|
||||
@@ -202,13 +203,13 @@ func (r *mutationResolver) ExportDocumentPDF(ctx context.Context, input types.Ex
|
||||
|
||||
if ndaExists {
|
||||
tokenData := TokenAccessFromContext(ctx)
|
||||
hasAcceptedNDA, err = privateTrustService.TrustCenterAccesses.HasAcceptedNonDisclosureAgreement(ctx, tokenData.TrustCenterID, tokenData.GetEmail())
|
||||
hasAcceptedNDA, err = privateTrustService.TrustCenterAccesses.HasAcceptedNonDisclosureAgreement(ctx, tokenData.TrustCenterID, tokenData.Email)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot check if user has accepted NDA: %w", err))
|
||||
}
|
||||
}
|
||||
|
||||
documentAccess, err := privateTrustService.TrustCenterAccesses.LoadDocumentAccess(ctx, tokenData.TrustCenterID, tokenData.GetEmail(), input.DocumentID)
|
||||
documentAccess, err := privateTrustService.TrustCenterAccesses.LoadDocumentAccess(ctx, tokenData.TrustCenterID, tokenData.Email, input.DocumentID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot check document access: %w", err))
|
||||
}
|
||||
@@ -223,12 +224,12 @@ func (r *mutationResolver) ExportDocumentPDF(ctx context.Context, input types.Ex
|
||||
}
|
||||
|
||||
userData := UserFromContext(ctx)
|
||||
userEmail := ""
|
||||
var userEmail mail.Addr
|
||||
if userData != nil {
|
||||
userEmail = userData.EmailAddress
|
||||
}
|
||||
if tokenData != nil {
|
||||
userEmail = tokenData.GetEmail()
|
||||
userEmail = tokenData.Email
|
||||
}
|
||||
|
||||
pdf, err := privateTrustService.Documents.ExportPDF(ctx, input.DocumentID, userEmail)
|
||||
@@ -280,13 +281,13 @@ func (r *mutationResolver) ExportReportPDF(ctx context.Context, input types.Expo
|
||||
}
|
||||
|
||||
if ndaExists {
|
||||
hasAcceptedNDA, err = privateTrustService.TrustCenterAccesses.HasAcceptedNonDisclosureAgreement(ctx, tokenData.TrustCenterID, tokenData.GetEmail())
|
||||
hasAcceptedNDA, err = privateTrustService.TrustCenterAccesses.HasAcceptedNonDisclosureAgreement(ctx, tokenData.TrustCenterID, tokenData.Email)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot check if user has accepted NDA: %w", err))
|
||||
}
|
||||
}
|
||||
|
||||
reportAccess, err := privateTrustService.TrustCenterAccesses.LoadReportAccess(ctx, tokenData.TrustCenterID, tokenData.GetEmail(), input.ReportID)
|
||||
reportAccess, err := privateTrustService.TrustCenterAccesses.LoadReportAccess(ctx, tokenData.TrustCenterID, tokenData.Email, input.ReportID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot check report access: %w", err))
|
||||
}
|
||||
@@ -301,12 +302,12 @@ func (r *mutationResolver) ExportReportPDF(ctx context.Context, input types.Expo
|
||||
}
|
||||
|
||||
userData := UserFromContext(ctx)
|
||||
userEmail := ""
|
||||
var userEmail mail.Addr
|
||||
if userData != nil {
|
||||
userEmail = userData.EmailAddress
|
||||
}
|
||||
if tokenData != nil {
|
||||
userEmail = tokenData.GetEmail()
|
||||
userEmail = tokenData.Email
|
||||
}
|
||||
|
||||
pdf, err := privateTrustService.Reports.ExportPDF(ctx, input.ReportID, userEmail)
|
||||
@@ -331,7 +332,7 @@ func (r *mutationResolver) AcceptNonDisclosureAgreement(ctx context.Context, inp
|
||||
return nil, fmt.Errorf("token not found")
|
||||
}
|
||||
|
||||
err = privateTrustService.TrustCenterAccesses.AcceptNonDisclosureAgreement(ctx, input.TrustCenterID, tokenData.GetEmail())
|
||||
err = privateTrustService.TrustCenterAccesses.AcceptNonDisclosureAgreement(ctx, input.TrustCenterID, tokenData.Email)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot accept NDA: %w", err)
|
||||
}
|
||||
@@ -360,11 +361,7 @@ func (r *mutationResolver) RequestDocumentAccess(ctx context.Context, input type
|
||||
email := input.Email
|
||||
tokenData := TokenAccessFromContext(ctx)
|
||||
if tokenData != nil {
|
||||
if email != nil || input.Name != nil {
|
||||
return nil, fmt.Errorf("email and name are not allowed for authenticated users")
|
||||
}
|
||||
emailValue := tokenData.GetEmail()
|
||||
email = &emailValue
|
||||
*email = tokenData.Email
|
||||
}
|
||||
if email == nil {
|
||||
return nil, fmt.Errorf("email is required for unauthenticated users")
|
||||
@@ -413,11 +410,7 @@ func (r *mutationResolver) RequestReportAccess(ctx context.Context, input types.
|
||||
email := input.Email
|
||||
tokenData := TokenAccessFromContext(ctx)
|
||||
if tokenData != nil {
|
||||
if email != nil || input.Name != nil {
|
||||
return nil, fmt.Errorf("email and name are not allowed for authenticated users")
|
||||
}
|
||||
emailValue := tokenData.GetEmail()
|
||||
email = &emailValue
|
||||
*email = tokenData.Email
|
||||
}
|
||||
if email == nil {
|
||||
return nil, fmt.Errorf("email is required for unauthenticated users")
|
||||
@@ -466,11 +459,7 @@ func (r *mutationResolver) RequestTrustCenterFileAccess(ctx context.Context, inp
|
||||
email := input.Email
|
||||
tokenData := TokenAccessFromContext(ctx)
|
||||
if tokenData != nil {
|
||||
if email != nil || input.Name != nil {
|
||||
return nil, fmt.Errorf("email and name are not allowed for authenticated users")
|
||||
}
|
||||
emailValue := tokenData.GetEmail()
|
||||
email = &emailValue
|
||||
*email = tokenData.Email
|
||||
}
|
||||
if email == nil {
|
||||
return nil, fmt.Errorf("email is required for unauthenticated users")
|
||||
@@ -538,13 +527,13 @@ func (r *mutationResolver) ExportTrustCenterFile(ctx context.Context, input type
|
||||
}
|
||||
|
||||
if ndaExists {
|
||||
hasAcceptedNDA, err = privateTrustService.TrustCenterAccesses.HasAcceptedNonDisclosureAgreement(ctx, tokenData.TrustCenterID, tokenData.GetEmail())
|
||||
hasAcceptedNDA, err = privateTrustService.TrustCenterAccesses.HasAcceptedNonDisclosureAgreement(ctx, tokenData.TrustCenterID, tokenData.Email)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot check if user has accepted NDA: %w", err))
|
||||
}
|
||||
}
|
||||
|
||||
fileAccess, err := privateTrustService.TrustCenterAccesses.LoadTrustCenterFileAccess(ctx, tokenData.TrustCenterID, tokenData.GetEmail(), input.TrustCenterFileID)
|
||||
fileAccess, err := privateTrustService.TrustCenterAccesses.LoadTrustCenterFileAccess(ctx, tokenData.TrustCenterID, tokenData.Email, input.TrustCenterFileID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot check trust center file access: %w", err))
|
||||
}
|
||||
@@ -559,12 +548,12 @@ func (r *mutationResolver) ExportTrustCenterFile(ctx context.Context, input type
|
||||
}
|
||||
|
||||
userData := UserFromContext(ctx)
|
||||
userEmail := ""
|
||||
var userEmail mail.Addr
|
||||
if userData != nil {
|
||||
userEmail = userData.EmailAddress
|
||||
}
|
||||
if tokenData != nil {
|
||||
userEmail = tokenData.GetEmail()
|
||||
userEmail = tokenData.Email
|
||||
}
|
||||
|
||||
fileData, err := privateTrustService.TrustCenterFiles.ExportFile(ctx, input.TrustCenterFileID, userEmail)
|
||||
@@ -743,7 +732,7 @@ func (r *reportResolver) IsUserAuthorized(ctx context.Context, obj *types.Report
|
||||
|
||||
tokenData := TokenAccessFromContext(ctx)
|
||||
if tokenData != nil {
|
||||
reportAccess, err := privateTrustService.TrustCenterAccesses.LoadReportAccess(ctx, tokenData.TrustCenterID, tokenData.GetEmail(), obj.ID)
|
||||
reportAccess, err := privateTrustService.TrustCenterAccesses.LoadReportAccess(ctx, tokenData.TrustCenterID, tokenData.Email, obj.ID)
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
@@ -768,7 +757,7 @@ func (r *reportResolver) HasUserRequestedAccess(ctx context.Context, obj *types.
|
||||
|
||||
tokenData := TokenAccessFromContext(ctx)
|
||||
if tokenData != nil {
|
||||
_, err := privateTrustService.TrustCenterAccesses.LoadReportAccess(ctx, tokenData.TrustCenterID, tokenData.GetEmail(), obj.ID)
|
||||
_, err := privateTrustService.TrustCenterAccesses.LoadReportAccess(ctx, tokenData.TrustCenterID, tokenData.Email, obj.ID)
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
@@ -822,7 +811,7 @@ func (r *trustCenterResolver) HasAcceptedNonDisclosureAgreement(ctx context.Cont
|
||||
|
||||
tokenData := TokenAccessFromContext(ctx)
|
||||
if tokenData != nil {
|
||||
hasAcceptedNDA, err := privateTrustService.TrustCenterAccesses.HasAcceptedNonDisclosureAgreement(ctx, obj.ID, tokenData.GetEmail())
|
||||
hasAcceptedNDA, err := privateTrustService.TrustCenterAccesses.HasAcceptedNonDisclosureAgreement(ctx, obj.ID, tokenData.Email)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot check if user has accepted NDA: %w", err))
|
||||
}
|
||||
@@ -947,7 +936,7 @@ func (r *trustCenterFileResolver) IsUserAuthorized(ctx context.Context, obj *typ
|
||||
|
||||
tokenData := TokenAccessFromContext(ctx)
|
||||
if tokenData != nil {
|
||||
fileAccess, err := privateTrustService.TrustCenterAccesses.LoadTrustCenterFileAccess(ctx, tokenData.TrustCenterID, tokenData.GetEmail(), obj.ID)
|
||||
fileAccess, err := privateTrustService.TrustCenterAccesses.LoadTrustCenterFileAccess(ctx, tokenData.TrustCenterID, tokenData.Email, obj.ID)
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
@@ -972,7 +961,7 @@ func (r *trustCenterFileResolver) HasUserRequestedAccess(ctx context.Context, ob
|
||||
|
||||
tokenData := TokenAccessFromContext(ctx)
|
||||
if tokenData != nil {
|
||||
_, err := privateTrustService.TrustCenterAccesses.LoadTrustCenterFileAccess(ctx, tokenData.TrustCenterID, tokenData.GetEmail(), obj.ID)
|
||||
_, err := privateTrustService.TrustCenterAccesses.LoadTrustCenterFileAccess(ctx, tokenData.TrustCenterID, tokenData.Email, obj.ID)
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user