Skip to content

Fix: set underage_when_given for consents

Bengfort requested to merge fix-underage-when-given into main

Consent.underage_when_given was added in !2269 (merged). It is used whether a consent was given by the parents of an underage subject so it can be invalidated when the subject turns full of age.

Unfortunately, we stopped setting this flag when we redesigned recruitment consent in !2365 (merged) (version 0.79.0, published on 2022-07-19). Since then, the consents of underage subjects have not been flagged and therefore they have not been invalidated.

Fortunately, we caught this in time. Subjects can give their own consent once they turn 16, but we only invalidate the parent's consent once they turn 18. The bug was introduced on less than 2 years ago, so there is no way an underage subject could be over 18 now.

The fix consists of two parts:

  • We start again to set the flag for new consents
  • We restore the flags for existing consents. This is possible because we know the date of birth of the subject and the date when the consent has been created. The flag just exists as a performance improvement.

Aside: The date of birth is actually optional. If it is not set we have no way of knowing whether the consent should expire at some date. There is probably a better way to handle this, but I decided to focus on the issue at hand first.

Merge request reports