openfun / joanie

πŸ‘› A headless ERP for education to manage course enrollment/subscription, payment and certificates delivery.
MIT License
20 stars 2 forks source link

πŸ›(backend) prevent to sign a document when signatories are missing #733

Closed jonathanreveille closed 3 months ago

jonathanreveille commented 3 months ago

This PR solves this issue

To avoid the situation where the organization has not set any owner members, it causes the contract to have only the student to sign the document where we actually need the signature of both parties. The problem is that if the organization does not have at least one owner, the signature procedure will be created with only 1 signature required. We need two signatures, one from the student and one from the organization to make the contract valid.

To avoid this issue in the future, we've added a new method that will verify if there is one user with the role 'owner' for the organization that is attached to the order.

Purpose

Prevent having a contract that is set as fully signed, but it has only been signed by the student. We must have both parties, the student and at least one of the owners of the organization attached to the order.

Proposal

Create a util method where we will check if there is still at least 1 owner for the organization that is attached to the order's organization.