mirror of https://github.com/jumpserver/jumpserver
perf: 优化登录前修改密码
parent
e3511df4f8
commit
5e5cd80bc2
|
@ -277,7 +277,7 @@ class PasswdTooSimple(JMSException):
|
||||||
|
|
||||||
class PasswdNeedUpdate(JMSException):
|
class PasswdNeedUpdate(JMSException):
|
||||||
default_code = 'passwd_need_update'
|
default_code = 'passwd_need_update'
|
||||||
default_detail = _('The administrator require you to change your password this time')
|
default_detail = _('You should to change your password before login')
|
||||||
|
|
||||||
def __init__(self, url, *args, **kwargs):
|
def __init__(self, url, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
|
@ -233,7 +233,6 @@ class AuthMixin:
|
||||||
)
|
)
|
||||||
raise errors.PasswdNeedUpdate(url)
|
raise errors.PasswdNeedUpdate(url)
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _check_password_require_reset_or_not(cls, user: User):
|
def _check_password_require_reset_or_not(cls, user: User):
|
||||||
if user.password_has_expired:
|
if user.password_has_expired:
|
||||||
|
|
|
@ -31,7 +31,8 @@ from ..forms import get_user_login_form_cls
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'UserLoginView', 'UserLogoutView',
|
'UserLoginView', 'UserLogoutView',
|
||||||
'UserLoginGuardView', 'UserLoginWaitConfirmView',
|
'UserLoginGuardView', 'UserLoginWaitConfirmView',
|
||||||
'FlashPasswdTooSimpleMsgView', 'FlashPasswdHasExpiredMsgView', 'FlashPasswdNeedUpdateMsgView'
|
'FlashPasswdTooSimpleMsgView', 'FlashPasswdHasExpiredMsgView',
|
||||||
|
'FlashPasswdNeedUpdateMsgView'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -218,7 +219,7 @@ class UserLogoutView(TemplateView):
|
||||||
context = {
|
context = {
|
||||||
'title': _('Logout success'),
|
'title': _('Logout success'),
|
||||||
'messages': _('Logout success, return login page'),
|
'messages': _('Logout success, return login page'),
|
||||||
'interval': 1,
|
'interval': 3,
|
||||||
'redirect_url': reverse('authentication:login'),
|
'redirect_url': reverse('authentication:login'),
|
||||||
'auto_redirect': True,
|
'auto_redirect': True,
|
||||||
}
|
}
|
||||||
|
@ -234,7 +235,7 @@ class FlashPasswdTooSimpleMsgView(TemplateView):
|
||||||
context = {
|
context = {
|
||||||
'title': _('Please change your password'),
|
'title': _('Please change your password'),
|
||||||
'messages': _('Your password is too simple, please change it for security'),
|
'messages': _('Your password is too simple, please change it for security'),
|
||||||
'interval': 5,
|
'interval': 3,
|
||||||
'redirect_url': request.GET.get('redirect_url'),
|
'redirect_url': request.GET.get('redirect_url'),
|
||||||
'auto_redirect': True,
|
'auto_redirect': True,
|
||||||
}
|
}
|
||||||
|
@ -248,10 +249,11 @@ class FlashPasswdNeedUpdateMsgView(TemplateView):
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
context = {
|
context = {
|
||||||
'title': _('Please change your password'),
|
'title': _('Please change your password'),
|
||||||
'messages': _('The administrator require you to change your password this time'),
|
'messages': _('You should to change your password before login'),
|
||||||
'interval': 8,
|
'interval': 3,
|
||||||
'redirect_url': request.GET.get('redirect_url'),
|
'redirect_url': request.GET.get('redirect_url'),
|
||||||
'auto_redirect': True,
|
'auto_redirect': True,
|
||||||
|
'confirm_button': _('Confirm')
|
||||||
}
|
}
|
||||||
return self.render_to_response(context)
|
return self.render_to_response(context)
|
||||||
|
|
||||||
|
@ -264,8 +266,9 @@ class FlashPasswdHasExpiredMsgView(TemplateView):
|
||||||
context = {
|
context = {
|
||||||
'title': _('Please change your password'),
|
'title': _('Please change your password'),
|
||||||
'messages': _('Your password has expired, please reset before logging in'),
|
'messages': _('Your password has expired, please reset before logging in'),
|
||||||
'interval': 5,
|
'interval': 3,
|
||||||
'redirect_url': request.GET.get('redirect_url'),
|
'redirect_url': request.GET.get('redirect_url'),
|
||||||
'auto_redirect': True,
|
'auto_redirect': True,
|
||||||
|
'confirm_button': _('Confirm')
|
||||||
}
|
}
|
||||||
return self.render_to_response(context)
|
return self.render_to_response(context)
|
||||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -31,7 +31,13 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-3">
|
<div class="col-lg-3">
|
||||||
<a href="{{ redirect_url }}" class="btn btn-primary block full-width m-b">{% trans 'Return' %}</a>
|
<a href="{{ redirect_url }}" class="btn btn-primary block full-width m-b">
|
||||||
|
{% if confirm_button %}
|
||||||
|
{{ confirm_button }}
|
||||||
|
{% else %}
|
||||||
|
{% trans 'Return' %}
|
||||||
|
{% endif %}
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue