Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding email addresses does not work for django-allauth-ui v. 1.1.6 under django-allauth v. 0.63.4 #95

Open
Naggafin opened this issue Jul 12, 2024 · 3 comments

Comments

@Naggafin
Copy link

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.

@danihodovic
Copy link
Owner

Do you want to take a stab at this? You can compare the templates between allauth and allauth_ui and deduce from there.

I'm guessing the problematic code is here:

@Naggafin
Copy link
Author

I can look into it. Busy schedule but simple enough fix. I'll submit a PR tomorrow.

@Naggafin
Copy link
Author

Oops. Didn't mean to close this

@Naggafin Naggafin reopened this Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants