diff options
author | Jan-Christoph Borchardt <hey@jancborchardt.net> | 2017-11-14 15:32:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-14 15:32:27 +0100 |
commit | 381967f35e11bfd04baa5c085f733793fee30858 (patch) | |
tree | ffb82fc88dab364f285cb802d87e4e5c3db47a41 /core/js | |
parent | 16549ae5fbc2165ab6cf0a1004f80cd142993d48 (diff) | |
parent | 15762c103bcff13de45e9bdff62ab7b2b390c218 (diff) | |
download | nextcloud-server-381967f35e11bfd04baa5c085f733793fee30858.tar.gz nextcloud-server-381967f35e11bfd04baa5c085f733793fee30858.zip |
Merge pull request #7013 from nextcloud/forgot-password
Directly show "Forgot password?" link, fix #6808
Diffstat (limited to 'core/js')
-rw-r--r-- | core/js/login.js | 17 | ||||
-rw-r--r-- | core/js/lostpassword.js | 85 |
2 files changed, 84 insertions, 18 deletions
diff --git a/core/js/login.js b/core/js/login.js index 81ef25ef2d4..012b4e0280e 100644 --- a/core/js/login.js +++ b/core/js/login.js @@ -12,12 +12,17 @@ */ OC.Login = _.extend(OC.Login || {}, { onLogin: function () { - $('#submit-icon') - .removeClass('icon-confirm-white') - .addClass('icon-loading-small'); - $('#submit') - .attr('value', t('core', 'Logging in …')); - return true; + // Only if password reset form is not active + if($('form[name=login][action]').length === 0) { + $('#submit-wrapper .submit-icon') + .removeClass('icon-confirm-white') + .addClass('icon-loading-small-dark'); + $('#submit') + .attr('value', t('core', 'Logging in …')); + $('.login-additional').fadeOut(); + return true; + } + return false; }, rememberLogin: function(){ diff --git a/core/js/lostpassword.js b/core/js/lostpassword.js index 1923b73a179..446d70d991e 100644 --- a/core/js/lostpassword.js +++ b/core/js/lostpassword.js @@ -14,12 +14,54 @@ OC.Lostpassword = { init : function() { $('#lost-password').click(OC.Lostpassword.resetLink); - $('#reset-password #submit').click(OC.Lostpassword.resetPassword); + $('#lost-password-back').click(OC.Lostpassword.backToLogin); + $('form[name=login]').submit(OC.Lostpassword.onSendLink); + OC.Lostpassword.resetButtons(); + }, + + resetButtons : function() { + $('#reset-password-wrapper .submit-icon') + .addClass('icon-confirm-white') + .removeClass('icon-loading-small-dark'); + $('#reset-password-submit') + .attr('value', t('core', 'Reset password')) + .prop('disabled', false); + $('#user').prop('disabled', false); + $('.login-additional').fadeIn(); + }, + + backToLogin : function(event) { + event.preventDefault(); + + $('#reset-password-wrapper').slideUp().fadeOut(); + $('#lost-password').slideDown().fadeIn(); + $('#lost-password-back').hide(); + $('.remember-login-container').slideDown().fadeIn(); + $('#submit-wrapper').slideDown().fadeIn(); + $('.groupbottom').slideDown().fadeIn(); + $('#user').parent().addClass('grouptop'); + $('#password').attr('required', true); + $('form[name=login]').removeAttr('action'); + $('#user').focus(); }, resetLink : function(event){ event.preventDefault(); - if (!$('#user').val().length){ + + $('#lost-password').hide(); + $('#lost-password-back').slideDown().fadeIn(); + $('.remember-login-container').slideUp().fadeOut(); + $('#submit-wrapper').slideUp().fadeOut(); + $('.groupbottom').slideUp().fadeOut(function(){ + $('#user').parent().removeClass('grouptop'); + }); + $('#reset-password-wrapper').slideDown().fadeIn(); + $('#password').attr('required', false); + $('form[name=login]').attr('action', 'lostpassword/email'); + $('#user').focus(); + + // Generate a browser warning for required fields if field empty + if ($('#user').val().length === 0) { $('#submit').trigger('click'); } else { if (OC.config.lost_password_link === 'disabled') { @@ -27,19 +69,37 @@ OC.Lostpassword = { } else if (OC.config.lost_password_link) { window.location = OC.config.lost_password_link; } else { - $.post( - OC.generateUrl('/lostpassword/email'), - { - user : $('#user').val() - }, - OC.Lostpassword.sendLinkDone - ).fail(function() { - OC.Lostpassword.sendLinkError(OC.Lostpassword.sendErrorMsg); - }); + OC.Lostpassword.onSendLink(); } } }, + onSendLink: function (event) { + // Only if password reset form is active + if($('form[name=login][action]').length === 1) { + if (event) { + event.preventDefault(); + } + $('#reset-password-wrapper .submit-icon') + .removeClass('icon-confirm-white') + .addClass('icon-loading-small-dark'); + $('#reset-password-submit') + .attr('value', t('core', 'Sending email …')) + .prop('disabled', true); + $('#user').prop('disabled', true); + $('.login-additional').fadeOut(); + $.post( + OC.generateUrl('/lostpassword/email'), + { + user : $('#user').val() + }, + OC.Lostpassword.sendLinkDone + ).fail(function() { + OC.Lostpassword.sendLinkError(OC.Lostpassword.sendErrorMsg); + }); + } + }, + sendLinkDone : function(result){ var sendErrorMsg; @@ -60,13 +120,14 @@ OC.Lostpassword = { // update is the better success message styling node.addClass('update').css({width:'auto'}); node.html(OC.Lostpassword.sendSuccessMsg); + OC.Lostpassword.resetButtons(); }, sendLinkError : function(msg){ var node = OC.Lostpassword.getSendStatusNode(); node.addClass('warning'); node.html(msg); - OC.Lostpassword.init(); + OC.Lostpassword.resetButtons(); }, getSendStatusNode : function(){ |