diff options
author | Julius Härtl <jus@bitgrid.net> | 2018-05-24 10:53:58 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2018-05-24 14:01:58 +0200 |
commit | 33b65faba020804e5fbe54d281eeb2dd384854f2 (patch) | |
tree | c4e903f598a9858eaf7b3d97cf296ab594f4996a /core | |
parent | fd4a7bf72a0c8a69325b1d63e6983021ac6651f8 (diff) | |
download | nextcloud-server-33b65faba020804e5fbe54d281eeb2dd384854f2.tar.gz nextcloud-server-33b65faba020804e5fbe54d281eeb2dd384854f2.zip |
Allow to specify custom text on admin password confirmation dialogs
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'core')
-rw-r--r-- | core/css/jquery.ocdialog.scss | 14 | ||||
-rw-r--r-- | core/js/js.js | 42 |
2 files changed, 43 insertions, 13 deletions
diff --git a/core/css/jquery.ocdialog.scss b/core/css/jquery.ocdialog.scss index a6ee3c6c57d..24cb426b18d 100644 --- a/core/css/jquery.ocdialog.scss +++ b/core/css/jquery.ocdialog.scss @@ -76,3 +76,17 @@ .oc-dialog-content { width: 100%; } + +.oc-dialog.password-confirmation { + .oc-dialog-content { + width: auto; + margin: 12px; + + input[type=password] { + width: 100%; + } + label { + display: none; + } + } +}
\ No newline at end of file diff --git a/core/js/js.js b/core/js/js.js index d7975804f4b..47fe4c4be58 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -1715,38 +1715,54 @@ OC.PasswordConfirmation = { /** * @param {function} callback */ - requirePasswordConfirmation: function(callback) { + requirePasswordConfirmation: function(callback, options) { + 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( - t( - 'core', - 'This action requires you to confirm your password' - ), - t('core','Authentication required'), + config.text, + config.title, function (result, password) { if (result && password !== '') { - self._confirmPassword(password); + self._confirmPassword(password, config); } }, true, - t('core','Password'), + 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); var $buttons = $dialog.find('button'); - $buttons.eq(0).text(t('core', 'Cancel')); - $buttons.eq(1).text(t('core', 'Confirm')); + $buttons.eq(0).hide(); + $buttons.eq(1).text(config.confirm); }); } this.callback = callback; }, - _confirmPassword: function(password) { + _confirmPassword: function(password, config) { var self = this; $.ajax({ @@ -1763,8 +1779,8 @@ OC.PasswordConfirmation = { } }, error: function() { - OC.PasswordConfirmation.requirePasswordConfirmation(self.callback); - OC.Notification.showTemporary(t('core', 'Failed to authenticate, try again')); + config.error = t('core', 'Failed to authenticate, try again'); + OC.PasswordConfirmation.requirePasswordConfirmation(self.callback, config); } }); } |