Skip to content

Commit

Permalink
feat(account): add request to email context
Browse files Browse the repository at this point in the history
  • Loading branch information
pennersr committed Dec 12, 2024
1 parent 9c9fa1c commit 0e52607
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions allauth/account/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,12 @@ def render_mail(self, template_prefix, email, context, headers=None):
msg.content_subtype = "html" # Main content is now text/html
return msg

def send_mail(self, template_prefix, email, context):
def send_mail(self, template_prefix: str, email: str, context: dict) -> None:
request = globals()["context"].request
ctx = {
"request": request,
"email": email,
"current_site": get_current_site(globals()["context"].request),
"current_site": get_current_site(request),
}
ctx.update(context)
msg = self.render_mail(template_prefix, email, ctx)
Expand Down Expand Up @@ -601,15 +603,14 @@ def get_email_confirmation_url(self, request, emailconfirmation):
def should_send_confirmation_mail(self, request, email_address, signup) -> bool:
return True

def send_account_already_exists_mail(self, email):
def send_account_already_exists_mail(self, email: str) -> None:
from allauth.account.internal import flows

signup_url = flows.signup.get_signup_url(context.request)
password_reset_url = flows.password_reset.get_reset_password_url(
context.request
)
ctx = {
"request": context.request,
"signup_url": signup_url,
"password_reset_url": password_reset_url,
}
Expand Down

0 comments on commit 0e52607

Please sign in to comment.