mirror of https://github.com/jumpserver/jumpserver
perf: 优化登录html
parent
da2dea5003
commit
26fc56b4be
|
@ -146,11 +146,9 @@
|
||||||
<form id="login-form" action="" method="post" role="form" novalidate="novalidate">
|
<form id="login-form" action="" method="post" role="form" novalidate="novalidate">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div style="line-height: 17px;margin-bottom: 20px;color: #999999;">
|
<div style="line-height: 17px;margin-bottom: 20px;color: #999999;">
|
||||||
{% if form.errors %}
|
|
||||||
<p class="help-block red-fonts">
|
|
||||||
{% if form.non_field_errors %}
|
{% if form.non_field_errors %}
|
||||||
|
<p class="help-block red-fonts">
|
||||||
{{ form.non_field_errors.as_text }}
|
{{ form.non_field_errors.as_text }}
|
||||||
{% endif %}
|
|
||||||
</p>
|
</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p class="welcome-message">
|
<p class="welcome-message">
|
||||||
|
@ -197,35 +195,15 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{% if AUTH_OPENID or AUTH_CAS or AUTH_WECOM or AUTH_DINGTALK or AUTH_FEISHU %}
|
{% if auth_methods %}
|
||||||
<div class="hr-line-dashed"></div>
|
<div class="hr-line-dashed"></div>
|
||||||
<div style="display: inline-block; float: left">
|
<div style="display: inline-block; float: left">
|
||||||
<b class="text-muted text-left" >{% trans "More login options" %}</b>
|
<b class="text-muted text-left" >{% trans "More login options" %}</b>
|
||||||
{% if AUTH_OPENID %}
|
{% for method in auth_methods %}
|
||||||
<a href="{% url 'authentication:openid:login' %}" class="more-login-item">
|
<a href="{{ method.url }}" class="more-login-item">
|
||||||
<i class="fa fa-openid"></i> {% trans 'OpenID' %}
|
<i class="fa"><img src="{{ method.logo }}" height="13" width="13"></i> {{ method.name }}
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endfor %}
|
||||||
{% if AUTH_CAS %}
|
|
||||||
<a href="{% url 'authentication:cas:cas-login' %}" class="more-login-item">
|
|
||||||
<i class="fa"><img src="{{ LOGIN_CAS_LOGO_URL }}" height="13" width="13"></i> {% trans 'CAS' %}
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
{% if AUTH_WECOM %}
|
|
||||||
<a href="{% url 'authentication:wecom-qr-login' %}" class="more-login-item">
|
|
||||||
<i class="fa"><img src="{{ LOGIN_WECOM_LOGO_URL }}" height="13" width="13"></i> {% trans 'WeCom' %}
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
{% if AUTH_DINGTALK %}
|
|
||||||
<a href="{% url 'authentication:dingtalk-qr-login' %}" class="more-login-item">
|
|
||||||
<i class="fa"><img src="{{ LOGIN_DINGTALK_LOGO_URL }}" height="13" width="13"></i> {% trans 'DingTalk' %}
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
{% if AUTH_FEISHU %}
|
|
||||||
<a href="{% url 'authentication:feishu-qr-login' %}" class="more-login-item">
|
|
||||||
<i class="fa"><img src="{{ LOGIN_FEISHU_LOGO_URL }}" height="13" width="13"></i> {% trans 'FeiShu' %}
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="text-center" style="display: inline-block;">
|
<div class="text-center" style="display: inline-block;">
|
||||||
|
|
|
@ -5,6 +5,7 @@ from __future__ import unicode_literals
|
||||||
import os
|
import os
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
from django.templatetags.static import static
|
||||||
from django.contrib.auth import login as auth_login, logout as auth_logout
|
from django.contrib.auth import login as auth_login, logout as auth_logout
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.shortcuts import reverse, redirect
|
from django.shortcuts import reverse, redirect
|
||||||
|
@ -136,6 +137,43 @@ class UserLoginView(mixins.AuthMixin, FormView):
|
||||||
self.request.session[RSA_PRIVATE_KEY] = None
|
self.request.session[RSA_PRIVATE_KEY] = None
|
||||||
self.request.session[RSA_PUBLIC_KEY] = None
|
self.request.session[RSA_PUBLIC_KEY] = None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_support_auth_methods():
|
||||||
|
auth_methods = [
|
||||||
|
{
|
||||||
|
'name': 'OpenID',
|
||||||
|
'enabled': settings.AUTH_OPENID,
|
||||||
|
'url': reverse('authentication:openid:login'),
|
||||||
|
'logo': static('img/login_oidc_logo.png')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'CAS',
|
||||||
|
'enabled': settings.AUTH_CAS,
|
||||||
|
'url': reverse('authentication:cas:cas-login'),
|
||||||
|
'logo': static('img/login_cas_logo.png')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': _('WeCom'),
|
||||||
|
'enabled': settings.AUTH_WECOM,
|
||||||
|
'url': reverse('authentication:wecom-qr-login'),
|
||||||
|
'logo': static('img/login_wecom_logo.png')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': _('DingTalk'),
|
||||||
|
'enabled': settings.AUTH_DINGTALK,
|
||||||
|
'url': reverse('authentication:dingtalk-qr-login'),
|
||||||
|
'logo': static('img/login_dingtalk_logo.png')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': _('FeiShu'),
|
||||||
|
'enabled': settings.AUTH_FEISHU,
|
||||||
|
'url': reverse('authentication:feishu-qr-login'),
|
||||||
|
'logo': static('img/login_feishu_logo.png')
|
||||||
|
}
|
||||||
|
]
|
||||||
|
return [method for method in auth_methods]
|
||||||
|
# return [method for method in auth_methods if method['enabled']]
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
forgot_password_url = reverse('authentication:forgot-password')
|
forgot_password_url = reverse('authentication:forgot-password')
|
||||||
has_other_auth_backend = settings.AUTHENTICATION_BACKENDS[0] != settings.AUTH_BACKEND_MODEL
|
has_other_auth_backend = settings.AUTHENTICATION_BACKENDS[0] != settings.AUTH_BACKEND_MODEL
|
||||||
|
@ -144,6 +182,8 @@ class UserLoginView(mixins.AuthMixin, FormView):
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'demo_mode': os.environ.get("DEMO_MODE"),
|
'demo_mode': os.environ.get("DEMO_MODE"),
|
||||||
|
'auth_methods': self.get_support_auth_methods(),
|
||||||
|
'has_other_auth'
|
||||||
'AUTH_OPENID': settings.AUTH_OPENID,
|
'AUTH_OPENID': settings.AUTH_OPENID,
|
||||||
'AUTH_CAS': settings.AUTH_CAS,
|
'AUTH_CAS': settings.AUTH_CAS,
|
||||||
'AUTH_WECOM': settings.AUTH_WECOM,
|
'AUTH_WECOM': settings.AUTH_WECOM,
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
Loading…
Reference in New Issue