diff options
author | Joas Schilling <coding@schilljs.com> | 2016-11-17 10:36:39 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2016-11-18 12:10:51 +0100 |
commit | 8d33d76ce8f8102f64d6b615dfc178b31e397e62 (patch) | |
tree | 6d3718454e702295640a67acbce12543c151a2cd /core/js/js.js | |
parent | e80d3c2a10ddc16e3608faa410ea93afc22750c5 (diff) | |
download | nextcloud-server-8d33d76ce8f8102f64d6b615dfc178b31e397e62.tar.gz nextcloud-server-8d33d76ce8f8102f64d6b615dfc178b31e397e62.zip |
Use the existing prompt
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core/js/js.js')
-rw-r--r-- | core/js/js.js | 64 |
1 files changed, 27 insertions, 37 deletions
diff --git a/core/js/js.js b/core/js/js.js index 4579fe394af..64c7dda31e2 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -1517,31 +1517,15 @@ function initCore() { } OC.PasswordConfirmation = { - $form: null, - $background: null, - $input: null, - $submit: null, callback: null, init: function() { - var self = this; - this.$form = $('#sudo-login-form'); - this.$background = $('#sudo-login-background'); - this.$input = this.$form.find('.question'); - this.$submit = this.$form.find('.confirm'); - - this.$background.on('click', _.bind(this._fadeOut, this)); $('.password-confirm-required').on('click', _.bind(this.requirePasswordConfirmation, this)); - this.$submit.on('click', _.bind(this._submitPasswordConfirmation, this)); - this.$input.keyup(function(e) { - if (e.keyCode === 13) { - self._submitPasswordConfirmation(); - } - }); }, requiresPasswordConfirmation: function() { var timeSinceLogin = moment.now() - nc_lastLogin * 1000; + return timeSinceLogin > 10 * 1000; // 30 minutes return timeSinceLogin > 30 * 60 * 1000; // 30 minutes }, @@ -1549,50 +1533,56 @@ OC.PasswordConfirmation = { * @param {function} callback */ requirePasswordConfirmation: function(callback) { + var self = this; + if (this.requiresPasswordConfirmation()) { - this.$form.removeClass('hidden'); - this.$background.removeClass('hidden'); - this.$input.val(''); + OC.dialogs.prompt( + t( + 'core', + 'This action requires you to confirm your password' + ), + t('core','Authentication required'), + function (result, password) { + if (result && password !== '') { + self._confirmPassword(password); + } + }, + true, + t('core','Password'), + true + ).then(function() { + var $dialog = $('.oc-dialog:visible'); + $dialog.find('.ui-icon').remove(); + + var $buttons = $dialog.find('button'); + $buttons.eq(0).text(t('core', 'Cancel')); + $buttons.eq(1).text(t('core', 'Confirm')); + }); } this.callback = callback; }, - _submitPasswordConfirmation: function() { + _confirmPassword: function(password) { var self = this; - self.$submit.removeClass('icon-confirm').addClass('icon-loading-small'); - $.ajax({ url: OC.generateUrl('/login/confirm'), data: { - password: this.$input.val() + password: password }, type: 'POST', success: function(response) { - self.$input.val(''); nc_lastLogin = response.lastLogin; - self.$submit.addClass('icon-confirm').removeClass('icon-loading-small'); - - self.$form.addClass('hidden'); - self.$background.addClass('hidden'); if (_.isFunction(self.callback)) { self.callback(); } }, error: function() { - self.$input.val(''); OC.Notification.showTemporary(t('core', 'Failed to authenticate, try again')); - self.$submit.addClass('icon-confirm').removeClass('icon-loading-small'); } }); - }, - - _fadeOut: function() { - this.$form.addClass('hidden'); - this.$background.addClass('hidden'); - this.$input.value = ''; } }; |