diff options
Diffstat (limited to 'core/js/js.js')
-rw-r--r-- | core/js/js.js | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/core/js/js.js b/core/js/js.js index d2d5ce5a817..f82b7e9cec5 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -1309,99 +1309,6 @@ function initCore() { OC.PasswordConfirmation.init(); } -OC.PasswordConfirmation = { - callback: null, - pageLoadTime: null, - init: function() { - $('.password-confirm-required').on('click', _.bind(this.requirePasswordConfirmation, this)); - this.pageLoadTime = moment.now(); - }, - - requiresPasswordConfirmation: function() { - var serverTimeDiff = this.pageLoadTime - (nc_pageLoad * 1000); - var timeSinceLogin = moment.now() - (serverTimeDiff + (nc_lastLogin * 1000)); - - // if timeSinceLogin > 30 minutes and user backend allows password confirmation - return (backendAllowsPasswordConfirmation && timeSinceLogin > 30 * 60 * 1000); - }, - - /** - * @param {function} callback - */ - requirePasswordConfirmation: function(callback, options, rejectCallback) { - options = typeof options !== 'undefined' ? options : {}; - var defaults = { - title: t('core','Authentication required'), - text: t( - 'core', - 'This action requires you to confirm your password' - ), - confirm: t('core', 'Confirm'), - label: t('core','Password'), - error: '', - }; - - var config = _.extend(defaults, options); - - var self = this; - - if (this.requiresPasswordConfirmation()) { - OC.dialogs.prompt( - config.text, - config.title, - function (result, password) { - if (result && password !== '') { - self._confirmPassword(password, config); - } else if (_.isFunction(rejectCallback)) { - rejectCallback() - } - }, - true, - config.label, - true - ).then(function() { - var $dialog = $('.oc-dialog:visible'); - $dialog.find('.ui-icon').remove(); - $dialog.addClass('password-confirmation'); - if (config.error !== '') { - var $error = $('<p></p>').addClass('msg warning').text(config.error); - } - $dialog.find('.oc-dialog-content').append($error); - $dialog.find('.oc-dialog-buttonrow').addClass('aside'); - - var $buttons = $dialog.find('button'); - $buttons.eq(0).hide(); - $buttons.eq(1).text(config.confirm); - }); - } - - this.callback = callback; - }, - - _confirmPassword: function(password, config) { - var self = this; - - $.ajax({ - url: OC.generateUrl('/login/confirm'), - data: { - password: password - }, - type: 'POST', - success: function(response) { - nc_lastLogin = response.lastLogin; - - if (_.isFunction(self.callback)) { - self.callback(); - } - }, - error: function() { - config.error = t('core', 'Failed to authenticate, try again'); - OC.PasswordConfirmation.requirePasswordConfirmation(self.callback, config); - } - }); - } -}; - $(document).ready(initCore); /** |