Force email addresses to be lower case
- Dominant language
- PHP
- Stars
- 156
- Forks
- 72
- Avg merge
- 12h 43m
- Merged PRs (30d)
- 203
Description
**This issue needs to be re-specified, it's not ready for implementation right now.**
We currently allow to store email addresses containing capital letters. This leads to some minor bugs, e.g. it is possible to invite the same email address multiple times with different capitalization: `castor@example.com` is treated as different from `Castor@example.com`. This circumvents our [unique index](https://github.com/ecamp/ecamp3/blob/devel/api/src/Entity/CampCollaboration.php#L86) on the inviteEmail column of CampCollaboration.
For modifying the input which users submit in various input fields, we have input filters. One example is `InputFilter\Trim`, which is used to trim whitespace from the start and end of input fields.
To fix the mixed-case email addresses, we should:
- [ ] Create a new input filter `InputFilter\Lowercase`, along with the `InputFilter\LowercaseFilter` class which actually performs the modification
- [ ] Add the `#[InputFilter\Lowercase]` annotation to Profile#email and Profile#newEmail
- [ ] Add the `#[InputFilter\Lowercase]` annotation to CampCollaboration#inviteEmail
- [ ] Add the `#[InputFilter\Lowercase]` annotation to ResetPassword#email
- [ ] Add unit tests for the `InputFilter\LowercaseFilter`, similar to the [tests for the trim filter](https://github.com/ecamp/ecamp3/blob/devel/api/tests/InputFilter/TrimFilterTest.php)
- [ ] Add API tests for all API operations which use the modified fields (create and update on these three entities), similar to the already [existing trim tests](https://github.com/ecamp/ecamp3/blob/devel/api/tests/Api/Profiles/UpdateProfileTest.php#L94)
- [ ] After the oauth flow we need to lowercase the email too, + search for the existing email with the lowercase email from the oauth flow
- [ ] Optional: Write a data migration to convert all existing data in the database to lower case. ⚠️ If there are already duplicate emails, we need a conflict resolution.
Maybe possible alternative:
- Use a collation for this field which ignores the case.
Contributor guide
Assessment
This issue has not been assessed yet.