diff options
author | 2019-10-06 21:27:11 +0100 | |
---|---|---|
committer | 2019-10-06 21:27:11 +0100 | |
commit | e736381dc00b495a853b4aa71f1a4f381f665a76 (patch) | |
tree | ac7da052eddeed1fe6ea25d567aad5c831c94283 /pydis_site/apps/home/apps.py | |
parent | Replace card on login page with notification (diff) |
Prevent saving emails, remove login page
Diffstat (limited to 'pydis_site/apps/home/apps.py')
-rw-r--r-- | pydis_site/apps/home/apps.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pydis_site/apps/home/apps.py b/pydis_site/apps/home/apps.py index 055d721b..a7c47dc5 100644 --- a/pydis_site/apps/home/apps.py +++ b/pydis_site/apps/home/apps.py @@ -1,3 +1,5 @@ +from typing import Any, Dict + from django.apps import AppConfig @@ -12,3 +14,25 @@ class HomeConfig(AppConfig): from pydis_site.apps.home.signals import SignalListener self.signal_listener = SignalListener() + self.patch_allauth() + + def patch_allauth(self) -> None: + """Monkey-patches Allauth classes so we never collect email addresses.""" + # Imported here because we can't import it before our apps are loaded up + from allauth.socialaccount.providers.base import Provider + + def extract_extra_data(_: Provider, data: Dict[str, Any]) -> Dict[str, Any]: + """ + Extracts extra data for a SocialAccount provided by Allauth. + + This is our version of this function that strips the email address from incoming extra + data. We do this so that we never have to store it. + + This is monkey-patched because most OAuth providers - or at least the ones we care + about - all use the function from the base Provider class. This means we don't have + to make a new Django app for each one we want to work with. + """ + data["email"] = "" + return data + + Provider.extract_extra_data = extract_extra_data |