django-allauth-ui
django-allauth-ui copied to clipboard
Adding email addresses does not work for django-allauth-ui v. 1.1.6 under django-allauth v. 0.63.4
I have the beginnings of a project utilizing django-allauth and django-allauth-ui setup. I have made no modifications to either django-allauth or django-allauth-ui, nor overridden any templates or project files. They're both stock and as-is. When launching my project to test out basic account functionality, I noticed that nothing happens when I log in as a user and go to add an email address for the first time. I set a breakpoint in the allauth email management view to discover the cause, and it appears to be right here:
# allauth.account.views
...
class EmailView(AjaxCapableProcessFormViewMixin, FormView):
...
def post(self, request, *args, **kwargs):
res = None
if "action_add" in request.POST: # <- problem is here: 'action_add' is not in the POST data
res = super(EmailView, self).post(request, *args, **kwargs)
elif request.POST.get("email"): # <- so it goes to this
if "action_send" in request.POST:
res = self._action_send(request)
elif "action_remove" in request.POST:
res = self._action_remove(request)
elif "action_primary" in request.POST:
res = self._action_primary(request)
res = res or HttpResponseRedirect(self.get_success_url()) # <- but none of the checks above pass, so this line is executed w/ res being a redirect
# Given that we bypassed AjaxCapableProcessFormViewMixin,
# we'll have to call invoke it manually...
res = _ajax_response(request, res, data=self._get_ajax_data_if())
else:
# No email address selected
res = HttpResponseRedirect(self.success_url)
res = _ajax_response(request, res, data=self._get_ajax_data_if())
return res
...
It appears, when submitting the form to add a new email address, that a required POST field is missing. and it reverts to the default behavior of redirecting to the success url. I would suspect that this behavior is not intended, as the way it stands currently is that it is impossible to add new email addresses. I believe a hidden form field is missing which adds the key being checked for to the POST data.