Check User and Group Create Date when Claiming Enterprise User
Source of this requirement: https://gitlab.com/gitlab-com/legal-and-compliance/-/issues/1298#note_1208366099
The legal definition of Enterprise User includes the following:
(2)The user account meets one of the following conditions:
- was created 2021-02-01 or later.
- has a SAML or SCIM identity tied to the organization's group.
- has a provisioned_by_group_id value that is the same as the organization's group's ID.
- is a member of the organization's group, where the subscription was purchased or renewed 2021-02-01 or later
Because we are doing an automatic claim when matching a verified domain, instead of using a SAML or SCIM identity, AND, there is no provisioned_by_group_id value (yet), we need to perform this date check.
Before we can automatically claim via verified domain, we need to check that:
- The user was created 2021-02-01 or later.
and/or
- The group's subscription was purchased or renewed 2021-02-01 or later
Proposal
Create a service class that will make a user "Enterprise User" if they meet the condition mentioned above. This implementation is intended to be used in multiple places in the codebase.
This class should also send e-mail notification:
Send an e-mail notification to the user (via notification address, if one is set - if not, send to primary) letting them know that they have an Enterprise Account.