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