mirror of https://github.com/jumpserver/jumpserver
[Bugfix] 修复用户登陆工单
parent
aeff0ab5f3
commit
f53cf8d544
|
@ -54,5 +54,6 @@ class LoginConfirmTicketStatusApi(mixins.AuthMixin, APIView):
|
|||
def delete(self, request, *args, **kwargs):
|
||||
ticket = self.get_ticket()
|
||||
if ticket:
|
||||
request.session.pop('auth_ticket_id', '')
|
||||
ticket.perform_status('closed', request.user)
|
||||
return Response('', status=200)
|
||||
|
|
|
@ -138,7 +138,7 @@ class NeedMoreInfoError(Exception):
|
|||
if error:
|
||||
self.error = error
|
||||
if msg:
|
||||
self.msg = ''
|
||||
self.msg = msg
|
||||
|
||||
def as_data(self):
|
||||
return {
|
||||
|
|
|
@ -115,7 +115,7 @@ class AuthMixin:
|
|||
|
||||
def get_ticket_or_create(self, confirm_setting):
|
||||
ticket = self.get_ticket()
|
||||
if not ticket:
|
||||
if not ticket or ticket.status == ticket.STATUS_CLOSED:
|
||||
ticket = confirm_setting.create_confirm_ticket(self.request)
|
||||
self.request.session['auth_ticket_id'] = str(ticket.id)
|
||||
return ticket
|
||||
|
|
|
@ -37,18 +37,18 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-3">
|
||||
<div class="col-sm-3">
|
||||
<a class="btn btn-primary btn-sm block btn-refresh">
|
||||
<i class="fa fa-refresh"></i> {% trans 'Refresh' %}
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<div class="col-sm-3">
|
||||
<a class="btn btn-primary btn-sm block btn-copy" data-link="{{ ticket_detail_url }}">
|
||||
<i class="fa fa-clipboard"></i> {% trans 'Copy link' %}
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<a class="btn btn-default btn-sm block btn-return" href="{% url 'authentication:login' %}">
|
||||
<div class="col-sm-3">
|
||||
<a class="btn btn-default btn-sm block btn-return">
|
||||
<i class="fa fa-reply"></i> {% trans 'Return' %}
|
||||
</a>
|
||||
</div>
|
||||
|
@ -82,6 +82,7 @@ function doRequestAuth() {
|
|||
method: "GET",
|
||||
success: function (data) {
|
||||
if (!data.error && data.msg === 'ok') {
|
||||
window.onbeforeunload = function(){};
|
||||
window.location = "{% url 'authentication:login-guard' %}"
|
||||
} else if (data.error !== "login_confirm_wait") {
|
||||
if (!errorMsgShow) {
|
||||
|
@ -125,17 +126,40 @@ function handleProgressBar() {
|
|||
progressBarRef.attr('aria-valuenow', offset);
|
||||
}
|
||||
|
||||
function cancelLoginConfirmTicket() {
|
||||
requestApi({
|
||||
url: url,
|
||||
method: "DELETE",
|
||||
flash_message: false
|
||||
})
|
||||
}
|
||||
|
||||
function cancelCloseConfirm() {
|
||||
window.onbeforeunload = function() {};
|
||||
window.onunload = function(){};
|
||||
}
|
||||
|
||||
function setCloseConfirm() {
|
||||
window.onbeforeunload = function (e) {
|
||||
return 'Confirm';
|
||||
};
|
||||
window.onunload = function (e) {
|
||||
cancelLoginConfirmTicket();
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
interval = setInterval(handleProgressBar, 1000);
|
||||
checkInterval = setInterval(doRequestAuth, 5000);
|
||||
doRequestAuth();
|
||||
initClipboard();
|
||||
window.onbeforeunload = function (e) {
|
||||
return "{% trans "Confirm" %}";
|
||||
};
|
||||
setCloseConfirm();
|
||||
}).on('click', '.btn-refresh', function () {
|
||||
window.onbeforeunload = function() {};
|
||||
cancelCloseConfirm();
|
||||
window.location.reload();
|
||||
}).on('click', '.btn-return', function () {
|
||||
cancelCloseConfirm();
|
||||
window.location = "{% url 'authentication:login' %}"
|
||||
})
|
||||
|
||||
</script>
|
||||
|
|
|
@ -152,8 +152,8 @@ class UserLoginWaitConfirmView(TemplateView):
|
|||
ticket = get_object_or_none(LoginConfirmTicket, pk=ticket_id)
|
||||
context = super().get_context_data(**kwargs)
|
||||
if ticket:
|
||||
ticket_detail_url = reverse('tickets:login-confirm-ticket-detail', kwargs={'pk': ticket_id})
|
||||
timestamp_created = datetime.datetime.timestamp(ticket.date_created)
|
||||
ticket_detail_url = reverse('tickets:login-confirm-ticket-detail', kwargs={'pk': ticket_id})
|
||||
msg = _("""Wait for <b>{}</b> confirm, You also can copy link to her/him <br/>
|
||||
Don't close this page""").format(ticket.assignees_display)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue