From fb057321643b726e13627037e27a93798cb55845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 11 May 2021 17:17:20 +0200 Subject: [PATCH] hook in registration view to set auth backend if required (#53757) --- src/authentic2_auth_fedict/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/authentic2_auth_fedict/__init__.py b/src/authentic2_auth_fedict/__init__.py index 72451db..a395eb8 100644 --- a/src/authentic2_auth_fedict/__init__.py +++ b/src/authentic2_auth_fedict/__init__.py @@ -29,6 +29,13 @@ class AppConfig(django.apps.AppConfig): user_logged_in.connect(signals.on_user_logged_in) + def a2_hook_event(self, name, **kwargs): + if name == 'registration': + logger = logging.getLogger(__name__) + if kwargs.get('authentication_method') == 'fedict': + user = kwargs.get('user') + user.backend = 'authentic2_auth_fedict.backends.FedictBackend' + default_app_config = 'authentic2_auth_fedict.AppConfig'