1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-20 07:55:06 +00:00

[2fa] login: redesign the UI

This commit is contained in:
llj 2017-12-25 16:04:57 +08:00
parent baeb8ccacf
commit 06894e3e52
2 changed files with 29 additions and 4 deletions

View File

@ -1,8 +1,9 @@
{% extends "base.html" %}
{% extends "registration/login.html" %}
{% load i18n %}
{% block main_content %}
<div class="new-narrow-panel">
<div class="login-panel-outer-container vh">
<div class="login-panel">
<h2 class="hd">{% trans "Two-Factor Authentication" %}</h2>
<form action="" method="post" class="con">{% csrf_token %}
{{ wizard.management_form }}
@ -26,12 +27,12 @@
{% else %}
<p class="error hide"></p>
{% endif %}
<button type="submit">{% trans "Verify" %}</button>
<button type="submit" class="btn-white">{% trans "Verify" %}</button>
{% if backup_tokens > 0 %}
<div class="two-factor-auth-login-no-phone">
<p class="txt-before-btn">{% trans "Don't have your phone?" %}</p>
<button name="wizard_goto_step" value="backup" type="submit">{% trans "Enter a two-factor backup code" %}</button>
<button name="wizard_goto_step" value="backup" type="submit" class="btn-white">{% trans "Enter a two-factor backup code" %}</button>
</div>
{% endif %}
@ -48,10 +49,22 @@
{% endif %}
</form>
</div>
</div>
{% endblock %}
{% block extra_script %}
<script type="text/javascript">
$('.login-panel-outer-container').prepend($($('#logo').html()).attr({'width': 160, 'height':40}).addClass('login-panel-logo'));
var $el = $('.login-panel-outer-container');
var elHeight = $el.outerHeight();
var wdHeight = $(window).height();
if (wdHeight > elHeight) {
$el.css({'margin-top': (wdHeight - elHeight)/2});
}
$el.removeClass('vh');
$('.new-narrow-panel .input').focus();
</script>
{% endblock %}

View File

@ -1,5 +1,6 @@
# Copyright (c) 2012-2016 Seafile Ltd.
import hashlib
import os
import re
import logging
from datetime import datetime
@ -34,6 +35,9 @@ from seahub.two_factor.forms import TOTPTokenAuthForm, BackupTokenAuthForm, Auth
from seahub.two_factor.utils import default_device
from seahub.two_factor.views.utils import class_view_decorator
from seahub.settings import LOGIN_BG_IMAGE_PATH, MEDIA_ROOT
from seahub.api2.endpoints.admin.login_bg_image import CUSTOM_LOGIN_BG_IMAGE_PATH
# Get an instance of a logger
logger = logging.getLogger(__name__)
@ -166,6 +170,14 @@ class TwoFactorVerifyView(SessionWizardView):
context['cancel_url'] = settings.LOGOUT_URL
context['form_prefix'] = '%s-' % self.steps.current
login_bg_image_path = LOGIN_BG_IMAGE_PATH
# get path that background image of login page
custom_login_bg_image_file = os.path.join(MEDIA_ROOT, CUSTOM_LOGIN_BG_IMAGE_PATH)
if os.path.exists(custom_login_bg_image_file):
login_bg_image_path = CUSTOM_LOGIN_BG_IMAGE_PATH
context['login_bg_image_path'] = login_bg_image_path
return context
def render_done(self, form, **kwargs):