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
0f399636
Commit
0f399636
authored
May 27, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of github.com:jumpserver/jumpserver into dev
parents
0847539e
f576f2ed
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
101 additions
and
17 deletions
+101
-17
settings.py
apps/jumpserver/settings.py
+1
-1
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
+2
-4
security_setting.html
apps/settings/templates/settings/security_setting.html
+2
-2
forms.py
apps/users/forms.py
+10
-0
_user.html
apps/users/templates/users/_user.html
+3
-0
user_create.html
apps/users/templates/users/user_create.html
+75
-7
user.py
apps/users/views/user.py
+8
-3
No files found.
apps/jumpserver/settings.py
View file @
0f399636
...
...
@@ -378,8 +378,8 @@ REST_FRAMEWORK = {
'rest_framework.parsers.JSONParser'
,
'rest_framework.parsers.FormParser'
,
'rest_framework.parsers.MultiPartParser'
,
'common.parsers.JMSCSVParser'
,
'rest_framework.parsers.FileUploadParser'
,
'common.parsers.JMSCSVParser'
),
'DEFAULT_AUTHENTICATION_CLASSES'
:
(
# 'rest_framework.authentication.BasicAuthentication',
...
...
apps/locale/zh/LC_MESSAGES/django.mo
View file @
0f399636
No preview for this file type
apps/locale/zh/LC_MESSAGES/django.po
View file @
0f399636
This diff is collapsed.
Click to expand it.
apps/settings/api.py
View file @
0f399636
...
...
@@ -220,7 +220,4 @@ class DjangoSettingsAPI(APIView):
data
[
k
]
=
v
except
(
json
.
JSONDecodeError
,
TypeError
):
data
[
k
]
=
str
(
v
)
return
Response
(
data
)
return
Response
(
data
)
\ No newline at end of file
apps/settings/templates/settings/security_setting.html
View file @
0f399636
...
...
@@ -33,8 +33,8 @@
</div>
<div
class=
"tab-content"
>
<div
class=
"col-sm-12"
style=
"padding-left:0"
>
<div
class=
"ibox-content"
style=
"border-width: 0;padding-top: 40px;"
>
<form
action=
""
method=
"post"
class=
"form-horizontal"
>
<div
class=
"ibox-content"
style=
"border-width: 0;padding-top: 40px;"
>
<form
action=
""
method=
"post"
class=
"form-horizontal"
>
{% if form.non_field_errors %}
<div
class=
"alert alert-danger"
>
{{ form.non_field_errors }}
...
...
apps/users/forms.py
View file @
0f399636
...
...
@@ -22,6 +22,12 @@ class UserCheckOtpCodeForm(forms.Form):
class
UserCreateUpdateForm
(
OrgModelForm
):
EMAIL_SET_PASSWORD
=
_
(
'Reset link will be generated and sent to the user'
)
CUSTOM_PASSWORD
=
_
(
'Set password'
)
PASSWORD_STRATEGY_CHOICES
=
(
(
0
,
EMAIL_SET_PASSWORD
),
(
1
,
CUSTOM_PASSWORD
)
)
role_choices
=
((
i
,
n
)
for
i
,
n
in
User
.
ROLE_CHOICES
if
i
!=
User
.
ROLE_APP
)
password
=
forms
.
CharField
(
label
=
_
(
'Password'
),
widget
=
forms
.
PasswordInput
,
...
...
@@ -36,6 +42,10 @@ class UserCreateUpdateForm(OrgModelForm):
widget
=
forms
.
Textarea
(
attrs
=
{
'placeholder'
:
_
(
'ssh-rsa AAAA...'
)}),
help_text
=
_
(
'Paste user id_rsa.pub here.'
)
)
password_strategy
=
forms
.
ChoiceField
(
choices
=
PASSWORD_STRATEGY_CHOICES
,
required
=
True
,
initial
=
0
,
widget
=
forms
.
RadioSelect
(),
label
=
_
(
'Password strategy'
)
)
class
Meta
:
model
=
User
...
...
apps/users/templates/users/_user.html
View file @
0f399636
...
...
@@ -74,6 +74,9 @@
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
();
$
(
'#id_date_expired'
).
daterangepicker
(
dateOptions
);
var
mfa_radio
=
$
(
'#id_otp_level'
);
mfa_radio
.
addClass
(
"form-inline"
);
mfa_radio
.
children
().
css
(
"margin-right"
,
"15px"
)
})
</script>
{% endblock %}
apps/users/templates/users/user_create.html
View file @
0f399636
...
...
@@ -2,15 +2,83 @@
{% load i18n %}
{% load bootstrap3 %}
{% block user_template_title %}{% trans "Create user" %}{% endblock %}
{#{% block username %}#}
{# {% bootstrap_field form.username layout="horizontal" %}#}
{#{% endblock %}#}
{% block password %}
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
{% trans 'Password' %}
</label>
<div
class=
"col-sm-8 controls"
style=
"margin-top: 8px;"
>
{% trans 'Reset link will be generated and sent to the user. ' %}
{% bootstrap_field form.password_strategy layout="horizontal" %}
<div
class=
"form-group"
id=
"custom_password"
>
{% bootstrap_field form.password layout="horizontal" %}
</div>
{# 密码popover #}
<div
id=
"container"
>
<div
class=
"popover fade bottom in"
role=
"tooltip"
id=
"popover777"
style=
" display: none; width:260px;"
>
<div
class=
"arrow"
style=
"left: 50%;"
></div>
<h3
class=
"popover-title"
style=
"display: none;"
></h3>
<h4>
{% trans 'Your password must satisfy' %}
</h4><div
id=
"id_password_rules"
style=
"color: #908a8a; margin-left:20px; font-size:15px;"
></div>
<h4
style=
"margin-top: 10px;"
>
{% trans 'Password strength' %}
</h4><div
id=
"id_progress"
></div>
<div
class=
"popover-content"
></div>
</div>
</div>
<script>
function
passwordCheck
()
{
if
(
$
(
'#id_password'
).
length
!=
1
)
{
return
}
var
el
=
$
(
'#id_password_rules'
),
idPassword
=
$
(
'#id_password'
),
idPopover
=
$
(
'#popover777'
),
container
=
$
(
'#container'
),
progress
=
$
(
'#id_progress'
),
password_check_rules
=
{{
password_check_rules
|
safe
}},
minLength
=
6
,
top
=
idPassword
.
offset
().
top
-
$
(
'.navbar'
).
outerHeight
(
true
)
-
$
(
'.page-heading'
).
outerHeight
(
true
)
-
10
+
34
,
left
=
377
,
i18n_fallback
=
{
"veryWeak"
:
"{% trans 'Very weak' %}"
,
"weak"
:
"{% trans 'Weak' %}"
,
"normal"
:
"{% trans 'Normal' %}"
,
"medium"
:
"{% trans 'Medium' %}"
,
"strong"
:
"{% trans 'Strong' %}"
,
"veryStrong"
:
"{% trans 'Very strong' %}"
};
$
.
each
(
password_check_rules
,
function
(
idx
,
rules
)
{
if
(
rules
.
key
===
'id_security_password_min_length'
){
minLength
=
rules
.
value
}
});
// 初始化popover
initPopover
(
container
,
progress
,
idPassword
,
el
,
password_check_rules
,
i18n_fallback
);
// 监听事件
idPassword
.
on
(
'focus'
,
function
()
{
idPopover
.
css
(
'top'
,
top
);
idPopover
.
css
(
'left'
,
left
);
idPopover
.
css
(
'display'
,
'block'
);
});
idPassword
.
on
(
'blur'
,
function
()
{
idPopover
.
css
(
'display'
,
'none'
);
});
idPassword
.
on
(
'keyup'
,
function
(){
var
password
=
idPassword
.
val
();
checkPasswordRules
(
password
,
minLength
);
});
}
var
password_strategy_radio_input
=
'input[type=radio][name=password_strategy]'
;
function
passwordStrategyFieldsDisplay
(){
var
val
=
$
(
'input:radio[name="password_strategy"]:checked'
).
val
();
if
(
val
===
'0'
){
$
(
'#custom_password'
).
addClass
(
'hidden'
)
}
else
{
$
(
'#custom_password'
).
removeClass
(
'hidden'
)
}
}
$
(
document
).
ready
(
function
()
{
passwordCheck
();
passwordStrategyFieldsDisplay
()
}).
on
(
'change'
,
password_strategy_radio_input
,
function
(){
passwordStrategyFieldsDisplay
()
})
</script>
{% endblock %}
apps/users/views/user.py
View file @
0f399636
...
...
@@ -81,9 +81,14 @@ class UserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateView):
success_message
=
create_success_msg
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
()
.
get_context_data
(
**
kwargs
)
context
.
update
({
'app'
:
_
(
'Users'
),
'action'
:
_
(
'Create user'
)})
return
context
check_rules
=
get_password_check_rules
()
context
=
{
'app'
:
_
(
'Users'
),
'action'
:
_
(
'Create user'
),
'password_check_rules'
:
check_rules
,
}
kwargs
.
update
(
context
)
return
super
()
.
get_context_data
(
**
kwargs
)
def
form_valid
(
self
,
form
):
user
=
form
.
save
(
commit
=
False
)
...
...
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