From a0d6c6593a4c6f08c2c4dd516c85ad59eb639be2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 19 Sep 2016 16:52:29 +0200 Subject: [PATCH] Allow to check it via the API Signed-off-by: Joas Schilling --- core/js/js.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/core/js/js.js b/core/js/js.js index bc99e1c77da..f498ed751c0 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -1521,6 +1521,7 @@ OC.PasswordConfirmation = { $background: null, $input: null, $submit: null, + callback: null, init: function() { this.$form = $('#sudo-login-form'); @@ -1533,9 +1534,16 @@ OC.PasswordConfirmation = { this.$submit.on('click', _.bind(this._submitPasswordConfirmation, this)); }, - requirePasswordConfirmation: function() { + requiresPasswordConfirmation: function() { var timeSinceLogin = moment.now() - nc_lastLogin * 1000; - if (timeSinceLogin > 30 * 60 * 1000) { // 30 minutes + return timeSinceLogin > 30 * 60 * 1000; // 30 minutes + }, + + /** + * @param {function} callback + */ + requirePasswordConfirmation: function(callback) { + if (this.requiresPasswordConfirmation()) { this.$form.removeClass('hidden'); this.$background.removeClass('hidden'); @@ -1544,6 +1552,8 @@ OC.PasswordConfirmation = { this.$input.val(''); } } + + this.callback = callback; }, _submitPasswordConfirmation: function() { @@ -1563,6 +1573,10 @@ OC.PasswordConfirmation = { self.$form.addClass('hidden'); self.$background.addClass('hidden'); + + if (!_.isUndefined(self.callback)) { + self.callback(); + } }, error: function() { OC.Notification.showTemporary(t('core', 'Failed to authenticate, try again')); -- 2.39.5