mirror of https://github.com/jumpserver/jumpserver
commit
5b6488e1b2
|
@ -76,7 +76,7 @@ $(document).ready(function () {
|
||||||
'ip': "{% trans 'IP' %}",
|
'ip': "{% trans 'IP' %}",
|
||||||
'protocols': "{% trans 'Protocols' %}",
|
'protocols': "{% trans 'Protocols' %}",
|
||||||
'platform': "{% trans 'Platform' %}",
|
'platform': "{% trans 'Platform' %}",
|
||||||
'system_users_join': "{% trans 'System user' %}",
|
{#'system_users_join': "{% trans 'System user' %}",#}
|
||||||
'domain': "{% trans 'Domain' %}",
|
'domain': "{% trans 'Domain' %}",
|
||||||
'comment': "{% trans 'Comment' %}",
|
'comment': "{% trans 'Comment' %}",
|
||||||
};
|
};
|
||||||
|
|
|
@ -135,6 +135,19 @@ $(document).ready(function () {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
requestApi(data)
|
requestApi(data)
|
||||||
|
}).on('click', '.btn-api-keydel', function (){
|
||||||
|
var url = "{% url "api-auth:access-key-detail" pk=DEFAULT_PK %}";
|
||||||
|
url = url.replace("{{ DEFAULT_PK }}", $(this).data("id")) ;
|
||||||
|
var data = {
|
||||||
|
url: url,
|
||||||
|
method: "DELETE",
|
||||||
|
success: function () {
|
||||||
|
ak_table.ajax.reload();
|
||||||
|
},
|
||||||
|
success_message: "{% trans 'Delete success' %}"
|
||||||
|
|
||||||
|
};
|
||||||
|
requestApi(data)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Binary file not shown.
|
@ -1671,7 +1671,7 @@ msgstr "定期测试系统用户可连接性: {}"
|
||||||
|
|
||||||
#: assets/tasks/utils.py:17
|
#: assets/tasks/utils.py:17
|
||||||
msgid "Asset has been disabled, skipped: {}"
|
msgid "Asset has been disabled, skipped: {}"
|
||||||
msgstr "资产或许不支持ansible, 跳过: {}"
|
msgstr "资产已经被禁用, 跳过: {}"
|
||||||
|
|
||||||
#: assets/tasks/utils.py:21
|
#: assets/tasks/utils.py:21
|
||||||
msgid "Asset may not be support ansible, skipped: {}"
|
msgid "Asset may not be support ansible, skipped: {}"
|
||||||
|
|
|
@ -19,10 +19,13 @@ class AdHocExecutionSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_stat(obj):
|
def get_stat(obj):
|
||||||
|
count_failed_hosts = len(obj.failed_hosts)
|
||||||
|
count_success_hosts = len(obj.success_hosts)
|
||||||
|
count_total = count_success_hosts + count_failed_hosts
|
||||||
return {
|
return {
|
||||||
"total": obj.hosts_amount,
|
"total": count_total,
|
||||||
"success": len(obj.summary.get("contacted", [])),
|
"success": count_success_hosts,
|
||||||
"failed": len(obj.summary.get("dark", [])),
|
"failed": count_failed_hosts
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_field_names(self, declared_fields, info):
|
def get_field_names(self, declared_fields, info):
|
||||||
|
|
|
@ -5,3 +5,7 @@ from django.apps import AppConfig
|
||||||
|
|
||||||
class PermsConfig(AppConfig):
|
class PermsConfig(AppConfig):
|
||||||
name = 'perms'
|
name = 'perms'
|
||||||
|
|
||||||
|
def ready(self):
|
||||||
|
super().ready()
|
||||||
|
from . import signals_handler
|
||||||
|
|
|
@ -218,7 +218,7 @@ function addGroups(groupsId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeGroup(groupId) {
|
function removeGroup(groupId) {
|
||||||
var theUrl = "{% url 'api-perms:asset-permissions-user-groups-relation-list' %}?assetpermission={{ object.id }}";
|
var theUrl = "{% url 'api-perms:asset-permissions-user-groups-relation-list' %}?assetpermission={{ object.id }}&usergroup=groupId";
|
||||||
theUrl = theUrl.replace("groupId", groupId);
|
theUrl = theUrl.replace("groupId", groupId);
|
||||||
var success = function(data) {
|
var success = function(data) {
|
||||||
location.reload();
|
location.reload();
|
||||||
|
|
|
@ -218,7 +218,7 @@ function addGroups(groupsId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeGroup(groupId) {
|
function removeGroup(groupId) {
|
||||||
var theUrl = "{% url 'api-perms:database-app-permissions-user-groups-relation-list' %}?databaseapppermission={{ object.id }}";
|
var theUrl = "{% url 'api-perms:database-app-permissions-user-groups-relation-list' %}?databaseapppermission={{ object.id }}&usergroup=groupId";
|
||||||
theUrl = theUrl.replace("groupId", groupId);
|
theUrl = theUrl.replace("groupId", groupId);
|
||||||
var success = function(data) {
|
var success = function(data) {
|
||||||
location.reload();
|
location.reload();
|
||||||
|
|
|
@ -179,9 +179,13 @@
|
||||||
var body = {
|
var body = {
|
||||||
user_groups: groups
|
user_groups: groups
|
||||||
};
|
};
|
||||||
|
var success = function(data) {
|
||||||
|
location.reload();
|
||||||
|
};
|
||||||
requestApi({
|
requestApi({
|
||||||
url: the_url,
|
url: the_url,
|
||||||
body: JSON.stringify(body)
|
body: JSON.stringify(body),
|
||||||
|
success: success
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
|
@ -83,26 +83,12 @@ class UserOtpEnableBindView(TemplateView, FormView):
|
||||||
return super().get_context_data(**kwargs)
|
return super().get_context_data(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
class UserVerifyMFAView(FormView):
|
class UserDisableMFAView(FormView):
|
||||||
template_name = 'users/user_verify_mfa.html'
|
template_name = 'users/user_verify_mfa.html'
|
||||||
form_class = forms.UserCheckOtpCodeForm
|
form_class = forms.UserCheckOtpCodeForm
|
||||||
success_url = reverse_lazy('users:user-otp-settings-success')
|
success_url = reverse_lazy('users:user-otp-settings-success')
|
||||||
permission_classes = [IsValidUser]
|
permission_classes = [IsValidUser]
|
||||||
|
|
||||||
def form_valid(self, form):
|
|
||||||
user = self.request.user
|
|
||||||
otp_code = form.cleaned_data.get('otp_code')
|
|
||||||
|
|
||||||
valid = user.check_mfa(otp_code)
|
|
||||||
if valid:
|
|
||||||
return super().form_valid(form)
|
|
||||||
else:
|
|
||||||
error = _('MFA code invalid, or ntp sync server time')
|
|
||||||
form.add_error('otp_code', error)
|
|
||||||
return super().form_invalid(form)
|
|
||||||
|
|
||||||
|
|
||||||
class UserDisableMFAView(UserVerifyMFAView):
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
user = self.request.user
|
user = self.request.user
|
||||||
otp_code = form.cleaned_data.get('otp_code')
|
otp_code = form.cleaned_data.get('otp_code')
|
||||||
|
@ -118,8 +104,23 @@ class UserDisableMFAView(UserVerifyMFAView):
|
||||||
return super().form_invalid(form)
|
return super().form_invalid(form)
|
||||||
|
|
||||||
|
|
||||||
class UserOtpUpdateView(UserVerifyMFAView):
|
class UserOtpUpdateView(FormView):
|
||||||
|
template_name = 'users/user_verify_mfa.html'
|
||||||
|
form_class = forms.UserCheckOtpCodeForm
|
||||||
success_url = reverse_lazy('users:user-otp-enable-bind')
|
success_url = reverse_lazy('users:user-otp-enable-bind')
|
||||||
|
permission_classes = [IsValidUser]
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
user = self.request.user
|
||||||
|
otp_code = form.cleaned_data.get('otp_code')
|
||||||
|
|
||||||
|
valid = user.check_mfa(otp_code)
|
||||||
|
if valid:
|
||||||
|
return super().form_valid(form)
|
||||||
|
else:
|
||||||
|
error = _('MFA code invalid, or ntp sync server time')
|
||||||
|
form.add_error('otp_code', error)
|
||||||
|
return super().form_invalid(form)
|
||||||
|
|
||||||
|
|
||||||
class UserOtpSettingsSuccessView(TemplateView):
|
class UserOtpSettingsSuccessView(TemplateView):
|
||||||
|
|
|
@ -67,7 +67,7 @@ class UserVerifyPasswordView(FormView):
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
user = get_user_or_pre_auth_user(self.request)
|
user = get_user_or_pre_auth_user(self.request)
|
||||||
password = form.cleaned_data.get('password')
|
password = form.cleaned_data.get('password')
|
||||||
user = authenticate(username=user.username, password=password)
|
user = authenticate(request=self.request, username=user.username, password=password)
|
||||||
if not user:
|
if not user:
|
||||||
form.add_error("password", _("Password invalid"))
|
form.add_error("password", _("Password invalid"))
|
||||||
return self.form_invalid(form)
|
return self.form_invalid(form)
|
||||||
|
|
Loading…
Reference in New Issue