Opened 6 years ago
Closed 6 years ago
#30499 closed New feature (invalid)
PasswordResetView should be allowed to set `domain_override`.
| Reported by: | Mattia Procopio | Owned by: | Mattia Procopio |
|---|---|---|---|
| Component: | Uncategorized | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Actually if the domain of the link sent within the mail needs to be overridden, the view form_valid method should be replaced or the view should subclass an own instance of PasswordContextMixin.
I think allowing to inject a custom domain from urls.py would help with DRY in this case as the new domain can be passed when declaring PasswordResetView.as_view(domain_override="mynew.domain.com")
I am thinking of adding simply domain_override = None as new class attribute and adding it to opts:
class PasswordResetView(PasswordContextMixin, FormView):
...
domain_override = None
def form_valid(self, form):
opts = {
'use_https': self.request.is_secure(),
'token_generator': self.token_generator,
'from_email': self.from_email,
'email_template_name': self.email_template_name,
'subject_template_name': self.subject_template_name,
'request': self.request,
'html_email_template_name': self.html_email_template_name,
'extra_email_context': self.extra_email_context,
'domain_override': self.domain_override,
}
form.save(**opts)
return super().form_valid(form)
Change History (4)
comment:1 by , 6 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:2 by , 6 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:4 by , 6 years ago
| Resolution: | → invalid |
|---|---|
| Status: | assigned → closed |
| Summary: | PasswordResetView should be allowed to set `domain_override` → PasswordResetView should be allowed to set `domain_override`. |
Mattia, Thanks for your work and sorry, but domain can be override easily with the current implementation, e.g.
views.PasswordResetView.as_view(extra_email_context={'domain': 'custom.example.com'}).
I think that providing an extra kwargs for that is pointless.
OK, yes, it seems a reasonable addition.