diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-05-24 17:47:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-24 17:47:02 +0200 |
commit | 6689a3e37b5bc71a66462c547072ad7555958c05 (patch) | |
tree | bd7173c362cee76893d9d13cdefc225c6cc7d8e5 /core | |
parent | fd4a7bf72a0c8a69325b1d63e6983021ac6651f8 (diff) | |
parent | d44cbc8118943a74906e0b6f554b14b860c67896 (diff) | |
download | nextcloud-server-6689a3e37b5bc71a66462c547072ad7555958c05.tar.gz nextcloud-server-6689a3e37b5bc71a66462c547072ad7555958c05.zip |
Merge pull request #9582 from nextcloud/feature/2593/password-confirm-texts
Allow custom text for OC.PasswordConfirmation
Diffstat (limited to 'core')
-rw-r--r-- | core/css/jquery.ocdialog.scss | 14 | ||||
-rw-r--r-- | core/js/js.js | 42 | ||||
-rw-r--r-- | core/js/oc-dialogs.js | 2 |
3 files changed, 44 insertions, 14 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); } }); } diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js index 97b9d91023d..3c3ed1469cb 100644 --- a/core/js/oc-dialogs.js +++ b/core/js/oc-dialogs.js @@ -122,7 +122,7 @@ var OCdialogs = { type : 'notice' }); var input = $('<input/>'); - input.attr('type', password ? 'password' : 'text').attr('id', dialogName + '-input'); + input.attr('type', password ? 'password' : 'text').attr('id', dialogName + '-input').attr('placeholder', name); var label = $('<label/>').attr('for', dialogName + '-input').text(name + ': '); $dlg.append(label); $dlg.append(input); |