Move trust GraphQL API under complianceportal v1
Relocate the public trust center GraphQL surface, OAuth handlers, and SPA serving into the compliance portal API package and remove the legacy trust v1 server tree. Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package complianceportal_v1
|
||||
|
||||
// This file will be automatically regenerated based on the schema, any resolver
|
||||
// implementations
|
||||
// will be copied through when generating and any unknown code will be moved to the end.
|
||||
// Code generated by github.com/99designs/gqlgen version v0.17.93
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.gearno.de/kit/log"
|
||||
trust "go.probo.inc/probo/pkg/complianceportal/visitor"
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/server/api/authn"
|
||||
"go.probo.inc/probo/pkg/server/api/complianceportal"
|
||||
"go.probo.inc/probo/pkg/server/api/complianceportal/v1/types"
|
||||
"go.probo.inc/probo/pkg/server/gqlutils"
|
||||
)
|
||||
|
||||
// CreateRightsRequest is the resolver for the createRightsRequest field.
|
||||
func (r *mutationResolver) CreateRightsRequest(ctx context.Context, input types.CreateRightsRequestInput) (*types.CreateRightsRequestPayload, error) {
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
if identity == nil || !identity.EmailAddressVerified {
|
||||
// The request is attributed to the viewer's email, so the email must be
|
||||
// verified — an authenticated-but-unverified identity is not enough.
|
||||
return nil, gqlutils.Unauthenticatedf(ctx, "a verified email is required to submit a request")
|
||||
}
|
||||
|
||||
compliancePage := complianceportal.CompliancePageFromContext(ctx)
|
||||
scope := coredata.NewScopeFromObjectID(compliancePage.OrganizationID)
|
||||
|
||||
rightsRequest, err := r.trust.CreateRightsRequest(
|
||||
ctx,
|
||||
scope,
|
||||
&trust.CreateRightsRequest{
|
||||
OrganizationID: compliancePage.OrganizationID,
|
||||
RequestType: input.RequestType,
|
||||
DataSubject: input.DataSubject,
|
||||
Contact: identity.EmailAddress.String(),
|
||||
Details: input.Details,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot create rights request", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return &types.CreateRightsRequestPayload{
|
||||
RightsRequestEdge: types.NewRightsRequestEdge(
|
||||
rightsRequest,
|
||||
coredata.RightsRequestOrderFieldCreatedAt,
|
||||
),
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user