esrg-knights / Squire

A re-introduction of the WebApp for ESRG Knights of the Kitchen Table.
https://www.kotkt.nl/
GNU General Public License v3.0
11 stars 8 forks source link

Registration emails #334

Closed EricTRL closed 11 months ago

EricTRL commented 1 year ago

Adds a registration form in the Member admin panel that allows sending a registration email to the registered member. This email allows the registered member to create (or log in to) a Squire account in order to link it to the registered membership data. This form also allows the admin to immediately add rooms or add a membership for an active year.

This works identical to Django's password reset emails. A token is generated and attached to a URL in an email. When visited, the URL token is verified and stored in the session data to prevent HTTP Referer leaks. Further views retrieve the token from the session data (and verify it again). Tokens expire in 3 days.

When a user that is not logged in visits the URL, they are redirected to a registration form with the option to also log in with an existing account. If a user is already logged in and visits the URL, they are redirected to a login form with no option for a new account registration. If the logged in user is already a member, or if (another) user was already linked to the member, the URL won't work.

A few utilities are introduced as well:

New dependencies:

Future work (not this PR):

codecov[bot] commented 1 year ago

Codecov Report

Attention: 10 lines in your changes are missing coverage. Please review.

Comparison is base (70e3d00) 95.84% compared to head (4de1905) 96.07%.

:exclamation: Current head 4de1905 differs from pull request most recent head 46320d1. Consider uploading reports for the commit 46320d1 to get more accurate results

Files Patch % Lines
membership_file/views.py 97.98% 1 Missing and 2 partials :warning:
membership_file/forms.py 98.23% 1 Missing and 1 partial :warning:
utils/testing/view_test_utils.py 80.00% 1 Missing and 1 partial :warning:
utils/views.py 94.44% 0 Missing and 2 partials :warning:
membership_file/models.py 75.00% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #334 +/- ## ========================================== + Coverage 95.84% 96.07% +0.23% ========================================== Files 161 163 +2 Lines 7118 7754 +636 Branches 1166 1283 +117 ========================================== + Hits 6822 7450 +628 - Misses 194 197 +3 - Partials 102 107 +5 ``` | [Flag](https://app.codecov.io/gh/esrg-knights/Squire/pull/334/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=esrg-knights) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/esrg-knights/Squire/pull/334/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=esrg-knights) | `96.07% <98.34%> (+0.23%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=esrg-knights#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

EricTRL commented 1 year ago

Some screenshots of the features can be found below

Screenshots Admin change list: ![image](https://github.com/esrg-knights/Squire/assets/34304046/55365af7-fa33-438d-b975-20c129710eae) Admin registration view: ![image](https://github.com/esrg-knights/Squire/assets/34304046/fe3bb688-e7db-45d1-968e-066275c2eed6) Registration success: ![image](https://github.com/esrg-knights/Squire/assets/34304046/4604fd82-f810-4a87-ac21-2d344c99771a) Re-send email (only if not already linked): ![image](https://github.com/esrg-knights/Squire/assets/34304046/ed978cc1-5ae7-455b-af04-348c110c7301) Admin re-send registration view ![Untitled](https://github.com/esrg-knights/Squire/assets/34304046/15e13624-3347-419b-bc66-a5230eb0bcb9) Email: ![image](https://github.com/esrg-knights/Squire/assets/34304046/f292865c-7b3f-47dd-ae42-713e65c0db67) Register page (email/real name are pre-filled) ![Untitled](https://github.com/esrg-knights/Squire/assets/34304046/64b427b1-6c18-4315-bd9e-367ac6efaf3f) Login (entering an account that already has a member) ![Untitled](https://github.com/esrg-knights/Squire/assets/34304046/e1c79a48-3a88-4c5e-8168-d755b014a939) Visiting the registration URL when already logged in (username pre-filled) ![Untitled](https://github.com/esrg-knights/Squire/assets/34304046/d1f601d2-fc5d-4ad4-9856-de6b8ecaa46e) Successful link ![Untitled](https://github.com/esrg-knights/Squire/assets/34304046/eae5b30a-cc70-4840-a4f1-2059b2006713) Error page ![Untitled](https://github.com/esrg-knights/Squire/assets/34304046/3496f2aa-7e0c-4fb9-ac27-f8951a74fc65)