From 42af7b3abc8c31fac77855d776d2cdd5bd0c5e32 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 11 Dec 2017 16:37:07 +0100 Subject: [PATCH] fix login based on the FC email only (fixes #20611) --- src/authentic2_auth_fc/views.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/authentic2_auth_fc/views.py b/src/authentic2_auth_fc/views.py index b69969f..ba03bdf 100644 --- a/src/authentic2_auth_fc/views.py +++ b/src/authentic2_auth_fc/views.py @@ -403,8 +403,19 @@ class LoginOrLinkView(PopupViewMixin, FcOAuthSessionViewMixin, View): token=self.token) else: self.logger.warning(u'account with email %s already linked to another sub ' - u'%s', + u'%s, linking is forbidden', email, user.fc_accounts.values_list('sub', flat=True)) + # we log the user using the email method as we did not really authenticate + # him using FC and we did not update its profile + self.logger.info(u'logged in using fc email "%s" and reconciliation with ' + u'an existing account', email) + messages.warning(request, + _('We could not link your account to you current ' + 'FranceConnect account, as your account is ' + 'already linked to another FranceConnect account, ' + 'please first unlink your account and retry')) + a2_utils.simulate_authentication(request, user, 'email') + return self.redirect(request) if user: a2_utils.login(request, user, 'france-connect') self.fc_account = models.FcAccount.objects.get(sub=self.sub, user=user) -- 2.1.4