views: do not permit linking if the user has already a link to FC (#20078)
This commit is contained in:
parent
e9b7ed137a
commit
a671f6c97c
|
@ -338,7 +338,14 @@ class LoginOrLinkView(PopupViewMixin, FcOAuthSessionViewMixin, View):
|
|||
except models.FcAccount.DoesNotExist:
|
||||
pass
|
||||
|
||||
# Old link are deleted
|
||||
# Prevent to add a link to an user which is already linked to an FC account
|
||||
if request.user.fc_accounts.exists():
|
||||
self.logger.warning(u'cannot link to sub %s, account is already linked to an '
|
||||
u'FC account', self.sub)
|
||||
messages.error(request,
|
||||
_('Your account is already linked to a FranceConnect account'))
|
||||
return self.redirect(request)
|
||||
|
||||
json_token = json.dumps(self.token)
|
||||
self.fc_account, created = models.FcAccount.objects.get_or_create(
|
||||
defaults={'token': json_token},
|
||||
|
|
Reference in New Issue