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
40a0c459
Commit
40a0c459
authored
Apr 25, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'github/dev' into dev
parents
9a3d0732
ea2863a5
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
4 deletions
+50
-4
asset_create.html
apps/assets/templates/assets/asset_create.html
+13
-1
asset.py
apps/assets/views/asset.py
+4
-1
_message.html
apps/templates/_message.html
+3
-1
forms.py
apps/users/forms.py
+8
-0
login.html
apps/users/templates/users/login.html
+1
-1
user_list.html
apps/users/templates/users/user_list.html
+3
-0
login.py
apps/users/views/login.py
+18
-0
No files found.
apps/assets/templates/assets/asset_create.html
View file @
40a0c459
...
@@ -15,9 +15,9 @@
...
@@ -15,9 +15,9 @@
{% csrf_token %}
{% csrf_token %}
<h3>
{% trans 'Basic' %}
</h3>
<h3>
{% trans 'Basic' %}
</h3>
{% bootstrap_field form.hostname layout="horizontal" %}
{% bootstrap_field form.hostname layout="horizontal" %}
{% bootstrap_field form.platform layout="horizontal" %}
{% bootstrap_field form.ip layout="horizontal" %}
{% bootstrap_field form.ip layout="horizontal" %}
{% bootstrap_field form.port layout="horizontal" %}
{% bootstrap_field form.port layout="horizontal" %}
{% bootstrap_field form.platform layout="horizontal" %}
{% bootstrap_field form.public_ip layout="horizontal" %}
{% bootstrap_field form.public_ip layout="horizontal" %}
{% bootstrap_field form.domain layout="horizontal" %}
{% bootstrap_field form.domain layout="horizontal" %}
...
@@ -85,6 +85,17 @@ $(document).ready(function () {
...
@@ -85,6 +85,17 @@ $(document).ready(function () {
allowClear
:
true
,
allowClear
:
true
,
templateSelection
:
format
templateSelection
:
format
});
});
$
(
"#id_platform"
).
change
(
function
(){
var
platform
=
$
(
"#id_platform option:selected"
).
text
();
var
port
=
22
;
if
(
platform
===
'Windows'
){
port
=
3389
;
}
if
(
platform
===
'Other'
){
port
=
null
;
}
$
(
"#id_port"
).
val
(
port
);
});
})
})
</script>
</script>
{% endblock %}
{% endblock %}
\ No newline at end of file
apps/assets/views/asset.py
View file @
40a0c459
...
@@ -304,7 +304,10 @@ class BulkImportAssetView(AdminUserRequiredMixin, JSONResponseMixin, FormView):
...
@@ -304,7 +304,10 @@ class BulkImportAssetView(AdminUserRequiredMixin, JSONResponseMixin, FormView):
if
v
!=
''
:
if
v
!=
''
:
asset_dict
[
k
]
=
v
asset_dict
[
k
]
=
v
asset
=
get_object_or_none
(
Asset
,
id
=
asset_dict
.
pop
(
'id'
,
0
))
asset
=
None
asset_id
=
asset_dict
.
pop
(
'id'
,
None
)
if
asset_id
:
asset
=
get_object_or_none
(
Asset
,
id
=
asset_id
)
if
not
asset
:
if
not
asset
:
try
:
try
:
if
len
(
Asset
.
objects
.
filter
(
hostname
=
asset_dict
.
get
(
'hostname'
))):
if
len
(
Asset
.
objects
.
filter
(
hostname
=
asset_dict
.
get
(
'hostname'
))):
...
...
apps/templates/_message.html
View file @
40a0c459
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
Your information was incomplete. Please click
<a
href=
"{{ first_login_url }}"
>
this link
</a>
to complete your information.
Your information was incomplete. Please click
<a
href=
"{{ first_login_url }}"
>
this link
</a>
to complete your information.
{% endblocktrans %}
{% endblocktrans %}
<button
aria-hidden=
"true"
data-dismiss=
"alert"
class=
"close"
type=
"button"
>
×
</button>
<button
aria-hidden=
"true"
data-dismiss=
"alert"
class=
"close"
type=
"button"
style=
"outline: none;"
>
×
</button>
</div>
</div>
{% endif %}
{% endif %}
{% endblock %}
{% endblock %}
...
@@ -28,7 +28,9 @@
...
@@ -28,7 +28,9 @@
{% for message in messages %}
{% for message in messages %}
<div
class=
"alert alert-{{ message.tags }} help-message"
>
<div
class=
"alert alert-{{ message.tags }} help-message"
>
{{ message|safe }}
{{ message|safe }}
<button
aria-hidden=
"true"
data-dismiss=
"alert"
class=
"close"
type=
"button"
style=
"outline: none;"
>
×
</button>
</div>
</div>
{% endfor %}
{% endfor %}
{% endif %}
{% endif %}
...
...
apps/users/forms.py
View file @
40a0c459
...
@@ -15,6 +15,14 @@ class UserLoginForm(AuthenticationForm):
...
@@ -15,6 +15,14 @@ class UserLoginForm(AuthenticationForm):
label
=
_
(
'Password'
),
widget
=
forms
.
PasswordInput
,
label
=
_
(
'Password'
),
widget
=
forms
.
PasswordInput
,
max_length
=
128
,
strip
=
False
max_length
=
128
,
strip
=
False
)
)
class
UserLoginCaptchaForm
(
AuthenticationForm
):
username
=
forms
.
CharField
(
label
=
_
(
'Username'
),
max_length
=
100
)
password
=
forms
.
CharField
(
label
=
_
(
'Password'
),
widget
=
forms
.
PasswordInput
,
max_length
=
128
,
strip
=
False
)
captcha
=
CaptchaField
()
captcha
=
CaptchaField
()
...
...
apps/users/templates/users/login.html
View file @
40a0c459
...
@@ -53,7 +53,7 @@
...
@@ -53,7 +53,7 @@
{% endif %}
{% endif %}
{% endif %}
{% endif %}
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<input
type=
"text"
class=
"form-control"
name=
"{{ form.username.html_name }}"
placeholder=
"{% trans 'Username' %}"
required=
""
>
<input
type=
"text"
class=
"form-control"
name=
"{{ form.username.html_name }}"
placeholder=
"{% trans 'Username' %}"
required=
""
value=
"{% if form.username.value %}{{ form.username.value }}{% endif %}"
>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<input
type=
"password"
class=
"form-control"
name=
"{{ form.password.html_name }}"
placeholder=
"{% trans 'Password' %}"
required=
""
>
<input
type=
"password"
class=
"form-control"
name=
"{{ form.password.html_name }}"
placeholder=
"{% trans 'Password' %}"
required=
""
>
...
...
apps/users/templates/users/user_list.html
View file @
40a0c459
...
@@ -107,6 +107,9 @@ $(document).ready(function(){
...
@@ -107,6 +107,9 @@ $(document).ready(function(){
$
(
'.btn_export'
).
click
(
function
()
{
$
(
'.btn_export'
).
click
(
function
()
{
var
users
=
[];
var
users
=
[];
var
rows
=
table
.
rows
(
'.selected'
).
data
();
var
rows
=
table
.
rows
(
'.selected'
).
data
();
if
(
rows
.
length
===
0
){
rows
=
table
.
rows
().
data
();
}
$
.
each
(
rows
,
function
(
index
,
obj
)
{
$
.
each
(
rows
,
function
(
index
,
obj
)
{
users
.
push
(
obj
.
id
)
users
.
push
(
obj
.
id
)
});
});
...
...
apps/users/views/login.py
View file @
40a0c459
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
import
os
import
os
from
django.core.cache
import
cache
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.contrib.auth
import
login
as
auth_login
,
logout
as
auth_logout
from
django.contrib.auth
import
login
as
auth_login
,
logout
as
auth_logout
from
django.contrib.auth.mixins
import
LoginRequiredMixin
from
django.contrib.auth.mixins
import
LoginRequiredMixin
...
@@ -43,7 +44,9 @@ __all__ = [
...
@@ -43,7 +44,9 @@ __all__ = [
class
UserLoginView
(
FormView
):
class
UserLoginView
(
FormView
):
template_name
=
'users/login.html'
template_name
=
'users/login.html'
form_class
=
forms
.
UserLoginForm
form_class
=
forms
.
UserLoginForm
form_class_captcha
=
forms
.
UserLoginCaptchaForm
redirect_field_name
=
'next'
redirect_field_name
=
'next'
key_prefix
=
"_LOGIN_INVALID_{}"
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
if
request
.
user
.
is_staff
:
if
request
.
user
.
is_staff
:
...
@@ -58,6 +61,21 @@ class UserLoginView(FormView):
...
@@ -58,6 +61,21 @@ class UserLoginView(FormView):
set_tmp_user_to_cache
(
self
.
request
,
form
.
get_user
())
set_tmp_user_to_cache
(
self
.
request
,
form
.
get_user
())
return
redirect
(
self
.
get_success_url
())
return
redirect
(
self
.
get_success_url
())
def
form_invalid
(
self
,
form
):
ip
=
get_login_ip
(
self
.
request
)
cache
.
set
(
self
.
key_prefix
.
format
(
ip
),
1
,
3600
)
old_form
=
form
form
=
self
.
form_class_captcha
(
data
=
form
.
data
)
form
.
_errors
=
old_form
.
errors
return
super
()
.
form_invalid
(
form
)
def
get_form_class
(
self
):
ip
=
get_login_ip
(
self
.
request
)
if
cache
.
get
(
self
.
key_prefix
.
format
(
ip
)):
return
self
.
form_class_captcha
else
:
return
self
.
form_class
def
get_success_url
(
self
):
def
get_success_url
(
self
):
user
=
get_user_or_tmp_user
(
self
.
request
)
user
=
get_user_or_tmp_user
(
self
.
request
)
...
...
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