mirror of https://github.com/jumpserver/jumpserver
perf: MFA认证App支持自定义下载二维码
parent
31b0d345ad
commit
1ae363d6bd
|
@ -3,6 +3,7 @@
|
||||||
path_perms_map = {
|
path_perms_map = {
|
||||||
'xpack': '*',
|
'xpack': '*',
|
||||||
'settings': '*',
|
'settings': '*',
|
||||||
|
'img': '*',
|
||||||
'replay': 'default',
|
'replay': 'default',
|
||||||
'applets': 'terminal.view_applet',
|
'applets': 'terminal.view_applet',
|
||||||
'virtual_apps': 'terminal.view_virtualapp',
|
'virtual_apps': 'terminal.view_virtualapp',
|
||||||
|
|
|
@ -14,22 +14,24 @@
|
||||||
</strong>
|
</strong>
|
||||||
</p>
|
</p>
|
||||||
<div>
|
<div>
|
||||||
<img src="{% static 'img/authenticator_android.png' %}" width="128" height="128" alt="">
|
<img src="{{ authenticator_android_url }}" width="128" height="128" alt="">
|
||||||
<p>{% trans 'Android downloads' %}</p>
|
<p>{% trans 'Android downloads' %}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<img src="{% static 'img/authenticator_iphone.png' %}" width="128" height="128" alt="">
|
<img src="{{ authenticator_iphone_url }}" width="128" height="128" alt="">
|
||||||
<p>{% trans 'iPhone downloads' %}</p>
|
<p>{% trans 'iPhone downloads' %}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p style="margin: 20px auto;"><strong style="color: #000000">{% trans 'After installation, click the next step to enter the binding page (if installed, go to the next step directly).' %}</strong></p>
|
<p style="margin: 20px auto;"><strong
|
||||||
|
style="color: #000000">{% trans 'After installation, click the next step to enter the binding page (if installed, go to the next step directly).' %}</strong>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a href="{% url 'authentication:user-otp-enable-bind' %}" class="next">{% trans 'Next' %}</a>
|
<a href="{% url 'authentication:user-otp-enable-bind' %}" class="next">{% trans 'Next' %}</a>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(function(){
|
$(function () {
|
||||||
$('.change-color li:eq(1) i').css('color', '{{ INTERFACE.primary_color }}')
|
$('.change-color li:eq(1) i').css('color', '{{ INTERFACE.primary_color }}')
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
# ~*~ coding: utf-8 ~*~
|
# ~*~ coding: utf-8 ~*~
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.contrib.auth import logout as auth_logout
|
from django.contrib.auth import logout as auth_logout
|
||||||
from django.http.response import HttpResponseRedirect
|
from django.http.response import HttpResponseRedirect
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
|
from django.templatetags.static import static
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
from django.utils._os import safe_join
|
||||||
from django.views.generic.base import TemplateView
|
from django.views.generic.base import TemplateView
|
||||||
from django.views.generic.edit import FormView
|
from django.views.generic.edit import FormView
|
||||||
|
|
||||||
|
@ -45,9 +49,26 @@ class UserOtpEnableStartView(AuthMixin, TemplateView):
|
||||||
class UserOtpEnableInstallAppView(TemplateView):
|
class UserOtpEnableInstallAppView(TemplateView):
|
||||||
template_name = 'users/user_otp_enable_install_app.html'
|
template_name = 'users/user_otp_enable_install_app.html'
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def replace_authenticator_png(platform):
|
||||||
|
media_url = settings.MEDIA_URL
|
||||||
|
base_path = f'img/authenticator_{platform}.png'
|
||||||
|
authenticator_media_path = safe_join(settings.MEDIA_ROOT, base_path)
|
||||||
|
if os.path.exists(authenticator_media_path):
|
||||||
|
authenticator_url = f'{media_url}{base_path}'
|
||||||
|
else:
|
||||||
|
authenticator_url = static(base_path)
|
||||||
|
return authenticator_url
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
user = get_user_or_pre_auth_user(self.request)
|
user = get_user_or_pre_auth_user(self.request)
|
||||||
context = {'user': user}
|
authenticator_android_url = self.replace_authenticator_png('android')
|
||||||
|
authenticator_iphone_url = self.replace_authenticator_png('iphone')
|
||||||
|
context = {
|
||||||
|
'user': user,
|
||||||
|
'authenticator_android_url': authenticator_android_url,
|
||||||
|
'authenticator_iphone_url': authenticator_iphone_url
|
||||||
|
}
|
||||||
kwargs.update(context)
|
kwargs.update(context)
|
||||||
return super().get_context_data(**kwargs)
|
return super().get_context_data(**kwargs)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue