Add nda to trust center
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -14,6 +14,12 @@
|
||||
|
||||
package coredata
|
||||
|
||||
type ctxKey struct{ name string }
|
||||
|
||||
var (
|
||||
ContextKeyIPAddress = &ctxKey{name: "ip_address"}
|
||||
)
|
||||
|
||||
const (
|
||||
OrganizationEntityType uint16 = iota
|
||||
FrameworkEntityType
|
||||
|
||||
10
pkg/coredata/migrations/20250909T114034Z.sql
Normal file
10
pkg/coredata/migrations/20250909T114034Z.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
ALTER TABLE trust_center_accesses ADD COLUMN has_accepted_non_disclosure_agreement BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ALTER TABLE trust_center_accesses ALTER COLUMN has_accepted_non_disclosure_agreement DROP DEFAULT;
|
||||
ALTER TABLE trust_center_accesses ADD COLUMN has_accepted_non_disclosure_agreement_metadata JSONB;
|
||||
|
||||
ALTER TABLE trust_centers ADD COLUMN non_disclosure_agreement_file_id TEXT;
|
||||
ALTER TABLE trust_centers ADD CONSTRAINT trust_centers_non_disclosure_agreement_file_id_fkey
|
||||
FOREIGN KEY (non_disclosure_agreement_file_id)
|
||||
REFERENCES files(id)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE RESTRICT;
|
||||
@@ -28,13 +28,14 @@ import (
|
||||
|
||||
type (
|
||||
TrustCenter struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
TenantID gid.TenantID `db:"tenant_id"`
|
||||
Active bool `db:"active"`
|
||||
Slug string `db:"slug"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
TenantID gid.TenantID `db:"tenant_id"`
|
||||
Active bool `db:"active"`
|
||||
Slug string `db:"slug"`
|
||||
NonDisclosureAgreementFileID *gid.GID `db:"non_disclosure_agreement_file_id"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
TrustCenters []*TrustCenter
|
||||
@@ -62,6 +63,7 @@ SELECT
|
||||
tenant_id,
|
||||
active,
|
||||
slug,
|
||||
non_disclosure_agreement_file_id,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -105,6 +107,7 @@ SELECT
|
||||
tenant_id,
|
||||
active,
|
||||
slug,
|
||||
non_disclosure_agreement_file_id,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -147,6 +150,7 @@ SELECT
|
||||
tenant_id,
|
||||
active,
|
||||
slug,
|
||||
non_disclosure_agreement_file_id,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -185,6 +189,7 @@ INSERT INTO trust_centers (
|
||||
tenant_id,
|
||||
active,
|
||||
slug,
|
||||
non_disclosure_agreement_file_id,
|
||||
created_at,
|
||||
updated_at
|
||||
) VALUES (
|
||||
@@ -193,19 +198,21 @@ INSERT INTO trust_centers (
|
||||
@tenant_id,
|
||||
@active,
|
||||
@slug,
|
||||
@non_disclosure_agreement_file_id,
|
||||
@created_at,
|
||||
@updated_at
|
||||
)
|
||||
`
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"id": tc.ID,
|
||||
"organization_id": tc.OrganizationID,
|
||||
"tenant_id": tc.TenantID,
|
||||
"active": tc.Active,
|
||||
"slug": tc.Slug,
|
||||
"created_at": tc.CreatedAt,
|
||||
"updated_at": tc.UpdatedAt,
|
||||
"id": tc.ID,
|
||||
"organization_id": tc.OrganizationID,
|
||||
"tenant_id": tc.TenantID,
|
||||
"active": tc.Active,
|
||||
"slug": tc.Slug,
|
||||
"non_disclosure_agreement_file_id": tc.NonDisclosureAgreementFileID,
|
||||
"created_at": tc.CreatedAt,
|
||||
"updated_at": tc.UpdatedAt,
|
||||
}
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
@@ -226,6 +233,7 @@ UPDATE trust_centers
|
||||
SET
|
||||
active = @active,
|
||||
slug = @slug,
|
||||
non_disclosure_agreement_file_id = @non_disclosure_agreement_file_id,
|
||||
updated_at = @updated_at
|
||||
WHERE
|
||||
%s
|
||||
@@ -235,10 +243,11 @@ WHERE
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"id": tc.ID,
|
||||
"active": tc.Active,
|
||||
"slug": tc.Slug,
|
||||
"updated_at": tc.UpdatedAt,
|
||||
"id": tc.ID,
|
||||
"active": tc.Active,
|
||||
"slug": tc.Slug,
|
||||
"non_disclosure_agreement_file_id": tc.NonDisclosureAgreementFileID,
|
||||
"updated_at": tc.UpdatedAt,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ package coredata
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"maps"
|
||||
@@ -29,14 +30,16 @@ import (
|
||||
|
||||
type (
|
||||
TrustCenterAccess struct {
|
||||
ID gid.GID `db:"id"`
|
||||
TenantID gid.TenantID `db:"tenant_id"`
|
||||
TrustCenterID gid.GID `db:"trust_center_id"`
|
||||
Email string `db:"email"`
|
||||
Name string `db:"name"`
|
||||
Active bool `db:"active"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
ID gid.GID `db:"id"`
|
||||
TenantID gid.TenantID `db:"tenant_id"`
|
||||
TrustCenterID gid.GID `db:"trust_center_id"`
|
||||
Email string `db:"email"`
|
||||
Name string `db:"name"`
|
||||
Active bool `db:"active"`
|
||||
HasAcceptedNonDisclosureAgreement bool `db:"has_accepted_non_disclosure_agreement"`
|
||||
HasAcceptedNonDisclosureAgreementMetadata json.RawMessage `db:"has_accepted_non_disclosure_agreement_metadata"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
TrustCenterAccesses []*TrustCenterAccess
|
||||
@@ -73,6 +76,8 @@ SELECT
|
||||
email,
|
||||
name,
|
||||
active,
|
||||
has_accepted_non_disclosure_agreement,
|
||||
has_accepted_non_disclosure_agreement_metadata,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -122,6 +127,8 @@ SELECT
|
||||
email,
|
||||
name,
|
||||
active,
|
||||
has_accepted_non_disclosure_agreement,
|
||||
has_accepted_non_disclosure_agreement_metadata,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -173,6 +180,7 @@ INSERT INTO trust_center_accesses (
|
||||
email,
|
||||
name,
|
||||
active,
|
||||
has_accepted_non_disclosure_agreement,
|
||||
created_at,
|
||||
updated_at
|
||||
) VALUES (
|
||||
@@ -182,20 +190,22 @@ INSERT INTO trust_center_accesses (
|
||||
@email,
|
||||
@name,
|
||||
@active,
|
||||
@has_accepted_non_disclosure_agreement,
|
||||
@created_at,
|
||||
@updated_at
|
||||
)
|
||||
`
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"id": tca.ID,
|
||||
"tenant_id": tca.TenantID,
|
||||
"trust_center_id": tca.TrustCenterID,
|
||||
"email": tca.Email,
|
||||
"name": tca.Name,
|
||||
"active": tca.Active,
|
||||
"created_at": tca.CreatedAt,
|
||||
"updated_at": tca.UpdatedAt,
|
||||
"id": tca.ID,
|
||||
"tenant_id": tca.TenantID,
|
||||
"trust_center_id": tca.TrustCenterID,
|
||||
"email": tca.Email,
|
||||
"name": tca.Name,
|
||||
"active": tca.Active,
|
||||
"has_accepted_non_disclosure_agreement": tca.HasAcceptedNonDisclosureAgreement,
|
||||
"created_at": tca.CreatedAt,
|
||||
"updated_at": tca.UpdatedAt,
|
||||
}
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
@@ -215,7 +225,9 @@ func (tca *TrustCenterAccess) Update(
|
||||
UPDATE trust_center_accesses SET
|
||||
name = @name,
|
||||
active = @active,
|
||||
updated_at = @updated_at
|
||||
updated_at = @updated_at,
|
||||
has_accepted_non_disclosure_agreement = @has_accepted_non_disclosure_agreement,
|
||||
has_accepted_non_disclosure_agreement_metadata = @has_accepted_non_disclosure_agreement_metadata
|
||||
WHERE
|
||||
%s
|
||||
AND id = @id
|
||||
@@ -224,10 +236,12 @@ WHERE
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"id": tca.ID,
|
||||
"name": tca.Name,
|
||||
"active": tca.Active,
|
||||
"updated_at": tca.UpdatedAt,
|
||||
"id": tca.ID,
|
||||
"name": tca.Name,
|
||||
"active": tca.Active,
|
||||
"updated_at": tca.UpdatedAt,
|
||||
"has_accepted_non_disclosure_agreement": tca.HasAcceptedNonDisclosureAgreement,
|
||||
"has_accepted_non_disclosure_agreement_metadata": tca.HasAcceptedNonDisclosureAgreementMetadata,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
@@ -281,6 +295,8 @@ SELECT
|
||||
email,
|
||||
name,
|
||||
active,
|
||||
has_accepted_non_disclosure_agreement,
|
||||
has_accepted_non_disclosure_agreement_metadata,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
|
||||
Reference in New Issue
Block a user