-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(accounts): Add notifications for account events
- Loading branch information
varun kumar
committed
Sep 30, 2023
1 parent
701ef63
commit 3440e5c
Showing
6 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from datetime import datetime | ||
|
||
from django.dispatch import receiver | ||
|
||
from .adapter import get_adapter | ||
from .signals import * | ||
|
||
|
||
def send_password_change_notification(sender, request, user, **kwargs): | ||
adapter = get_adapter() | ||
template_prefix = "account/email/password_changed_notification" | ||
context = { | ||
"timestamp": datetime.now(), | ||
"username": user.username, | ||
"ip": adapter.get_client_ip(request), | ||
"browser_agent": adapter.get_browser_user_agent(request), | ||
} | ||
adapter.send_notification_mail(template_prefix, user, context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{% load i18n %} | ||
|
||
Hello {{ username }}, | ||
|
||
We wanted to let you know that there has been a recent change to your account information. | ||
|
||
Here are the details of the change: | ||
|
||
{% block content %} | ||
{% endblock %} | ||
|
||
Change details | ||
IP address : {{ip}} | ||
Browser agent : {{browser_agent}} | ||
|
||
|
||
If this change was not made by you, please contact us immediately at support of {{site_name}}. | ||
|
||
|
6 changes: 6 additions & 0 deletions
6
allauth/templates/account/email/password_changed_notification_message.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{% extends "account/email/base_notification.txt" %} | ||
{% load i18n %} | ||
|
||
{% block content %}{% blocktrans %}Your Password has been changed | ||
|
||
Changes made by {{ username }}.{% endblocktrans %}{% endblock content %} |
4 changes: 4 additions & 0 deletions
4
allauth/templates/account/email/password_changed_notification_subject.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{% load i18n %} | ||
{% autoescape off %} | ||
{% blocktrans %}Your Password has been changed{% endblocktrans %} | ||
{% endautoescape %} |