Cancel signature requests on deactivation
Disabling a profile now removes pending document signature requests tied to that signatory. This keeps inactive accounts from retaining signature work across manual, archived, and SCIM deactivation flows. Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Bryan FRIMIN <bryan@frimin.fr>
This commit is contained in:
committed by
Bryan Frimin
parent
122bc02a23
commit
f7309c642a
@@ -373,6 +373,36 @@ WHERE
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pvss *DocumentVersionSignatures) DeleteRequestedBySignatory(
|
||||
ctx context.Context,
|
||||
conn pg.Tx,
|
||||
scope Scoper,
|
||||
signatoryID gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
DELETE FROM document_version_signatures
|
||||
WHERE
|
||||
%s
|
||||
AND signed_by_profile_id = @signatory_id
|
||||
AND state = @state
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"signatory_id": signatoryID,
|
||||
"state": DocumentVersionSignatureStateRequested,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot delete requested document version signatures: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pvss *DocumentVersionSignaturesWithPeople) LoadByDocumentVersionIDWithPeople(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
|
||||
@@ -425,6 +425,11 @@ func (s *OrganizationService) ArchiveUser(
|
||||
return fmt.Errorf("cannot expire pending invitations: %w", err)
|
||||
}
|
||||
|
||||
signatures := &coredata.DocumentVersionSignatures{}
|
||||
if err := signatures.DeleteRequestedBySignatory(ctx, tx, scope, profile.ID); err != nil {
|
||||
return fmt.Errorf("cannot delete requested signatures: %w", err)
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
|
||||
if profile.State != coredata.ProfileStateInactive {
|
||||
@@ -1161,6 +1166,13 @@ func (s *OrganizationService) UpdateUserState(
|
||||
return fmt.Errorf("cannot update profile: %w", err)
|
||||
}
|
||||
|
||||
if state == coredata.ProfileStateInactive {
|
||||
signatures := &coredata.DocumentVersionSignatures{}
|
||||
if err := signatures.DeleteRequestedBySignatory(ctx, tx, scope, profile.ID); err != nil {
|
||||
return fmt.Errorf("cannot delete requested signatures: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
@@ -299,6 +299,11 @@ func (s *Service) CreateUser(
|
||||
); err != nil {
|
||||
return fmt.Errorf("cannot expire pending invitations: %w", err)
|
||||
}
|
||||
|
||||
signatures := &coredata.DocumentVersionSignatures{}
|
||||
if err := signatures.DeleteRequestedBySignatory(ctx, tx, scope, profile.ID); err != nil {
|
||||
return fmt.Errorf("cannot delete requested signatures: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
membership = &coredata.Membership{}
|
||||
@@ -729,6 +734,11 @@ func (s *Service) updateUser(
|
||||
); err != nil {
|
||||
return fmt.Errorf("cannot expire pending invitations: %w", err)
|
||||
}
|
||||
|
||||
signatures := &coredata.DocumentVersionSignatures{}
|
||||
if err := signatures.DeleteRequestedBySignatory(ctx, tx, scope, profile.ID); err != nil {
|
||||
return fmt.Errorf("cannot delete requested signatures: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
needsUpdate := shouldReactivate || shouldDeactivate
|
||||
|
||||
Reference in New Issue
Block a user