Ask password at unlinking when the user has no usable password (fixes #10524) (ter).

This commit is contained in:
Mikaël Ates 2016-04-14 10:44:13 +02:00
parent 5704e98495
commit d3d9aab919
1 changed files with 4 additions and 3 deletions

View File

@ -385,9 +385,10 @@ class UnlinkView(LoggerMixin, SingleObjectMixin, FormView):
return ctx
def form_valid(self, form):
form.save()
self.logger.info(u'user %s has set a password', self.fc_account.user)
self.fc_account.user.backend = 'authentic2.backends.models_backend.ModelBackend'
if not self.fc_account.user.has_usable_password():
form.save()
self.logger.info(u'user %s has set a password', self.fc_account.user)
self.fc_account.user.backend = 'authentic2.backends.models_backend.ModelBackend'
msg_tpl = _('The link with the FranceConnect account {fc_account} has been deleted.')
msg = msg_tpl.format(fc_account=self.fc_account)
self.logger.info(u'user %s unlinked from %s', self.fc_account.user, self.fc_account)