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

Bugfix/#724 #1212

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions cadasta/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
from django.conf import settings
from django.db import models
from django.dispatch import receiver
from django.template import Context
from django.template.loader import get_template
from django.utils.translation import ugettext as _
from django.core.mail import send_mail
from allauth.account.signals import password_changed, password_reset
import django.contrib.auth.models as auth
import django.contrib.auth.base_user as auth_base
from tutelary.models import Policy
Expand Down Expand Up @@ -89,3 +93,18 @@ def assign_default_policy(sender, instance, **kwargs):
if policy not in assigned_policies:
assigned_policies.insert(0, policy)
instance.assign_policies(*assigned_policies)


@receiver(password_changed)
@receiver(password_reset)
def password_changed_reset(sender, request, user, **kwargs):
msg_body = get_template(
"accounts/email/password_change_successful.txt"
).render(Context({'user': user}))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The context is not used in the template; there's no need to create and pass it.

send_mail(
_("Password Successfully Changed or Reset"),
msg_body,
settings.DEFAULT_FROM_EMAIL,
[user.email],
fail_silently=False
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% load i18n %}{% autoescape off %}
{% trans "You are receiving this email because someone has changed or reset the password for your account at Cadasta Platform. If it wasn't you, please contact us immediately under" %} [email protected]
{% endautoescape %}