]> source.dussan.org Git - nextcloud-server.git/commitdiff
Disable login button until the timezone is set
authorVincent Petry <pvince81@owncloud.com>
Wed, 14 May 2014 15:00:15 +0000 (17:00 +0200)
committerVincent Petry <pvince81@owncloud.com>
Wed, 14 May 2014 15:00:15 +0000 (17:00 +0200)
On slow computers it might happen that the user manages to login before
the timezone code has a chance to run, which then causes dates to appear
wrong in the UI.

This fix makes sure the login cannot happen until the timezone field is
set.

Note that it's not possible to run the timezone code outside of
document.ready() because at that time the DOM element doesn't exist yet.

core/js/visitortimezone.js
core/templates/login.php

index ee0105c783d4e969116d12ac43efa8c55631c7ae..d9b63a108798456c060cdb0640a3ca009cf2ae94 100644 (file)
@@ -1,4 +1,10 @@
 $(document).ready(function () {
                var visitortimezone = (-new Date().getTimezoneOffset() / 60);
                $('#timezone-offset').val(visitortimezone);
+
+               // only enable the submit button once we are sure that the timezone is set
+               var $loginForm = $('form[name="login"]');
+               if ($loginForm.length) {
+                       $loginForm.find('input#submit').prop('disabled', false);
+               }
 });
index 65f760c1ee84e4f56667cceb24e045cb8c4d5e0f..669d20b32e415fc16bfc613bc618a6189f172cde 100644 (file)
@@ -51,7 +51,7 @@
                <label for="remember_login"><?php p($l->t('remember')); ?></label>
                <?php endif; ?>
                <input type="hidden" name="timezone-offset" id="timezone-offset"/>
-               <input type="submit" id="submit" class="login primary" value="<?php p($l->t('Log in')); ?>"/>
+               <input type="submit" id="submit" class="login primary" value="<?php p($l->t('Log in')); ?>" disabled="disabled"/>
        </fieldset>
 </form>
 <?php if (!empty($_['alt_login'])) { ?>