mirror of https://github.com/zulip/zulip.git
enails: Pass new login details as separate variables.
Refactored by tabbott to eliminate some unnecessary complexity.
This commit is contained in:
parent
363d17f2bb
commit
b72874226f
|
@ -11,9 +11,9 @@
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p>Server: <a href="{{ realm_uri }}" target="_blank">{{ realm_uri }}</a></p>
|
<p>Server: <a href="{{ realm_uri }}" target="_blank">{{ realm_uri }}</a></p>
|
||||||
<p>Account: <a href="mailto:{{ user_email }}" target="_blank">{{ user_email }}</a></p>
|
<p>Account: <a href="mailto:{{ user_email }}" target="_blank">{{ user_email }}</a></p>
|
||||||
<p>Time: {{ device_info.login_time }}</p>
|
<p>Time: {{ login_time }}</p>
|
||||||
<p>Device: {{ device_info.device_browser if device_info.device_browser else 'An unknown browser' }} on {{ device_info.device_os if device_info.device_os else 'an unknown operating system' }}.</p>
|
<p>Device: {{ device_browser if device_browser else 'An unknown browser' }} on {{ device_os if device_os else 'an unknown operating system' }}.</p>
|
||||||
<p>IP Address: {{ device_info.device_ip }}</p>
|
<p>IP Address: {{ device_ip }}</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<p>If you do not recognize this login activity, or think your account may have been compromised, please contact us immediately at <a href="mailto:{{ support_email }}">{{ support_email }}</a>.</p>
|
<p>If you do not recognize this login activity, or think your account may have been compromised, please contact us immediately at <a href="mailto:{{ support_email }}">{{ support_email }}</a>.</p>
|
||||||
<p>If you recognize this login activity, you can archive this notice.</p>
|
<p>If you recognize this login activity, you can archive this notice.</p>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
New login from {{ device_info.device_browser if device_info.device_browser else 'an unknown browser' }} on {{ device_info.device_os if device_info.device_os else 'an unknown operating system' }}
|
New login from {{ device_browser if device_browser else 'an unknown browser' }} on {{ device_os if device_os else 'an unknown operating system' }}
|
||||||
|
|
|
@ -5,9 +5,9 @@ This is a notification that a new login to your Zulip account has just occurred.
|
||||||
Login details:
|
Login details:
|
||||||
Server: {{ realm_uri }}
|
Server: {{ realm_uri }}
|
||||||
Account: {{ user_email }}
|
Account: {{ user_email }}
|
||||||
Time: {{ device_info.login_time }}
|
Time: {{ login_time }}
|
||||||
Device: {{ device_info.device_browser if device_info.device_browser else 'an unknown browser' }} on {{ device_info.device_os if device_info.device_os else 'an unknown operating system' }}.
|
Device: {{ device_browser if device_browser else 'an unknown browser' }} on {{ device_os if device_os else 'an unknown operating system' }}.
|
||||||
IP Address: {{ device_info.device_ip }}
|
IP Address: {{ device_ip }}
|
||||||
|
|
||||||
If you do not recognize this login activity, or think your account may have
|
If you do not recognize this login activity, or think your account may have
|
||||||
been compromised, please contact us immediately at {{ support_email }}.
|
been compromised, please contact us immediately at {{ support_email }}.
|
||||||
|
|
|
@ -67,21 +67,15 @@ def email_on_new_login(sender: Any, user: UserProfile, request: Any, **kwargs: A
|
||||||
if getattr(user, "just_registered", False):
|
if getattr(user, "just_registered", False):
|
||||||
return
|
return
|
||||||
|
|
||||||
login_time = timezone_now().strftime('%A, %B %d, %Y at %I:%M%p ') + \
|
|
||||||
timezone_get_current_timezone_name()
|
|
||||||
user_agent = request.META.get('HTTP_USER_AGENT', "").lower()
|
user_agent = request.META.get('HTTP_USER_AGENT', "").lower()
|
||||||
device_browser = get_device_browser(user_agent)
|
|
||||||
device_os = get_device_os(user_agent)
|
|
||||||
device_ip = request.META.get('REMOTE_ADDR') or "Uknown IP address"
|
|
||||||
device_info = {"device_browser": device_browser,
|
|
||||||
"device_os": device_os,
|
|
||||||
"device_ip": device_ip,
|
|
||||||
"login_time": login_time
|
|
||||||
}
|
|
||||||
|
|
||||||
context = common_context(user)
|
context = common_context(user)
|
||||||
context['device_info'] = device_info
|
|
||||||
context['user_email'] = user.email
|
context['user_email'] = user.email
|
||||||
|
context['login_time'] = timezone_now().strftime('%A, %B %d, %Y at %I:%M%p ') + \
|
||||||
|
timezone_get_current_timezone_name()
|
||||||
|
context['device_ip'] = request.META.get('REMOTE_ADDR') or "Uknown IP address"
|
||||||
|
context['device_os'] = get_device_os(user_agent)
|
||||||
|
context['device_browser'] = get_device_browser(user_agent)
|
||||||
|
|
||||||
email_dict = {
|
email_dict = {
|
||||||
'template_prefix': 'zerver/emails/notify_new_login',
|
'template_prefix': 'zerver/emails/notify_new_login',
|
||||||
|
|
Loading…
Reference in New Issue