mirror of https://github.com/jumpserver/jumpserver
perf: 工单直接审批者访问链接无认证跳转到登录页面 (#11902)
* perf: 工单直接审批者访问链接无认证跳转到登录页面 * perf: 修改重定向登录地址 * perf: 跳转字段标识更新pull/11909/head
parent
ca0dca26c7
commit
03d1a187df
|
@ -39,7 +39,6 @@
|
|||
<form id="approve-form" action="" method="post" role="form" novalidate="novalidate">
|
||||
{% csrf_token %}
|
||||
<div class="form-group" style="">
|
||||
{% if user.is_authenticated %}
|
||||
<button class="btn btn-primary block full-width m-b" name="action" value="approve"
|
||||
type="submit">
|
||||
{% trans 'Approval' %}
|
||||
|
@ -48,12 +47,6 @@
|
|||
type="submit">
|
||||
{% trans 'Reject' %}
|
||||
</button>
|
||||
{% else %}
|
||||
<a id='login_button' class="btn btn-primary block full-width m-b"
|
||||
href="{{ login_url }}">
|
||||
{% trans 'Go Login' %}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -64,30 +64,28 @@ class TicketDirectApproveView(TemplateView):
|
|||
|
||||
def get_context_data(self, **kwargs):
|
||||
# 放入工单信息
|
||||
token = kwargs.get('token')
|
||||
content = cache.get(token, {}).get('content', [])
|
||||
if self.request.user.is_authenticated:
|
||||
prompt_msg = _('Click the button below to approve or reject')
|
||||
else:
|
||||
prompt_msg = _('After successful authentication, this ticket can be approved directly')
|
||||
kwargs.update({
|
||||
'content': content, 'prompt_msg': prompt_msg,
|
||||
'login_url': '%s&next=%s' % (
|
||||
self.login_url,
|
||||
reverse('tickets:direct-approve', kwargs={'token': token})
|
||||
),
|
||||
'content': kwargs['ticket_info'].get('content', []),
|
||||
'prompt_msg': _('Click the button below to approve or reject'),
|
||||
})
|
||||
return super().get_context_data(**kwargs)
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
if not request.user.is_authenticated:
|
||||
return HttpResponse(status=401)
|
||||
direct_url = reverse('tickets:direct-approve', kwargs={'token': kwargs['token']})
|
||||
message_data = {
|
||||
'title': _('Ticket approval'),
|
||||
'message': _('After successful authentication, this ticket can be approved directly'),
|
||||
'redirect_url': f'{self.login_url}&{self.redirect_field_name}={direct_url}',
|
||||
'auto_redirect': True,
|
||||
}
|
||||
redirect_url = FlashMessageUtil.gen_message_url(message_data)
|
||||
return redirect(redirect_url)
|
||||
|
||||
token = kwargs.get('token')
|
||||
ticket_info = cache.get(token)
|
||||
ticket_info = cache.get(kwargs['token'])
|
||||
if not ticket_info:
|
||||
return self.redirect_message_response(redirect_url=self.login_url)
|
||||
return super().get(request, *args, **kwargs)
|
||||
return super().get(request, ticket_info=ticket_info, *args, **kwargs)
|
||||
|
||||
def post(self, request, **kwargs):
|
||||
user = request.user
|
||||
|
|
Loading…
Reference in New Issue