mirror of https://github.com/jumpserver/jumpserver
Merge remote-tracking branch 'github/dev' into dev
commit
40a0c4597b
|
@ -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 () {
|
||||||
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 %}
|
|
@ -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'))):
|
||||||
|
|
|
@ -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 @@
|
||||||
{% 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 %}
|
||||||
|
|
||||||
|
|
|
@ -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()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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="">
|
||||||
|
|
|
@ -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)
|
||||||
});
|
});
|
||||||
|
|
|
@ -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__ = [
|
||||||
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):
|
||||||
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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue