pennersr / django-allauth

Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication.
https://allauth.org
MIT License
9.55k stars 3.04k forks source link

Add email to context for email confirmation emails (and potentially others) #2647

Closed getup8 closed 11 months ago

getup8 commented 4 years ago

I'm curious why the email address itself (that the email is sent to) isn't sent in the context to the template, e.g.

https://github.com/pennersr/django-allauth/blob/e49df55815e13a3e59e51fc9e4764f3af2a035d0/allauth/account/adapter.py#L444-L449

In the case where people use specific versions of their emails to sign up (e.g. myname+suffix@gmail.com) or have their emails forwarded from elsewhere, I think it's nice to actually display the email address that's being confirmed in the email itself.

Let me know your thoughts!

Somewhat related to #2516 and #2186

iarp commented 4 years ago

That wouldn't be to difficult of a PR for someone to make, you already have access to emailconfirmation.email_address. I would pass the full object in case someone also wants to check its verified or primary -ness then just use something like email.email for the actual email address depending on ctx key used.

getup8 commented 4 years ago

Yeah right now I'm actually just doing this since email is already passed into render_mail(...)

    def render_mail(self, template_prefix, email, context):
        """
        Override so we can inject the email address itself into the context.

        Opened a bug for this:
        https://github.com/pennersr/django-allauth/issues/2647
        """
        # Add email address to context.
        context['email_address'] = email
        return super(CustomAccountAdapter, self).render_mail(
            template_prefix, email, context)

Agree, it would likely be a small PR. I am not adept at contributing but will try to take a look this week.

derek-adair commented 1 year ago

I am not adept at contributing but will try to take a look this week.

@getup8

image

derek-adair commented 1 year ago

Seems the relevant issues this user linked are closed, maybe this is fixed already? If not it's a good small thing to do.

pennersr commented 11 months ago

Closed via a778398e