Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
87c7452d
Commit
87c7452d
authored
Oct 21, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改email msg
parent
f3dc9b88
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
15 deletions
+26
-15
django.mo
apps/locale/zh/LC_MESSAGES/django.mo
+0
-0
django.po
apps/locale/zh/LC_MESSAGES/django.po
+0
-0
api.py
apps/settings/api.py
+13
-1
utils.py
apps/users/utils.py
+13
-14
No files found.
apps/locale/zh/LC_MESSAGES/django.mo
View file @
87c7452d
No preview for this file type
apps/locale/zh/LC_MESSAGES/django.po
View file @
87c7452d
This diff is collapsed.
Click to expand it.
apps/settings/api.py
View file @
87c7452d
...
...
@@ -5,6 +5,7 @@ import os
import
json
import
jms_storage
from
smtplib
import
SMTPSenderRefused
from
rest_framework
import
generics
from
rest_framework.views
import
Response
,
APIView
from
django.conf
import
settings
...
...
@@ -41,9 +42,20 @@ class MailTestingAPI(APIView):
email_from
=
email_from
or
email_host_user
email_recipient
=
email_recipient
or
email_from
send_mail
(
subject
,
message
,
email_from
,
[
email_recipient
])
except
SMTPSenderRefused
as
e
:
resp
=
e
.
smtp_error
if
isinstance
(
resp
,
bytes
):
for
coding
in
(
'gbk'
,
'utf8'
):
try
:
resp
=
resp
.
decode
(
coding
)
except
UnicodeDecodeError
:
continue
else
:
break
return
Response
({
"error"
:
str
(
resp
)},
status
=
401
)
except
Exception
as
e
:
print
(
e
)
return
Response
({
"error"
:
str
(
e
)},
status
=
401
)
return
Response
({
"msg"
:
self
.
success_message
.
format
(
email_recipient
)})
else
:
return
Response
({
"error"
:
str
(
serializer
.
errors
)},
status
=
401
)
...
...
apps/users/utils.py
View file @
87c7452d
...
...
@@ -22,21 +22,20 @@ logger = logging.getLogger('jumpserver')
def
construct_user_created_email_body
(
user
):
default_body
=
_
(
"""
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<p style="text-indent:2em;">
<span>
Username:
%(username)
s.
</span>
<span>
<a href="
%(rest_password_url)
s?token=
%(rest_password_token)
s">click here to set your password</a>
</span>
<span>
This link is valid for 1 hour. After it expires, <a href="
%(forget_password_url)
s?email=
%(email)
s">request new one</a>
</span>
<span>
<div>
<p>Your account has been created successfully</p>
<div>
Username:
%(username)
s
<br/>
Password: <a href="
%(rest_password_url)
s?token=
%(rest_password_token)
s">
click here to set your password</a>
(This link is valid for 1 hour. After it expires, <a href="
%(forget_password_url)
s?email=
%(email)
s">request new one</a>)
</div>
<div>
<p>---</p>
<a href="
%(login_url)
s">Login direct</a>
</
span
>
</
p
>
</
div
>
</
div
>
"""
)
%
{
'username'
:
user
.
username
,
'rest_password_url'
:
reverse
(
'users:reset-password'
,
external
=
True
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment