summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-05-24 17:47:02 +0200
committerGitHub <noreply@github.com>2018-05-24 17:47:02 +0200
commit6689a3e37b5bc71a66462c547072ad7555958c05 (patch)
treebd7173c362cee76893d9d13cdefc225c6cc7d8e5
parentfd4a7bf72a0c8a69325b1d63e6983021ac6651f8 (diff)
parentd44cbc8118943a74906e0b6f554b14b860c67896 (diff)
downloadnextcloud-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
-rw-r--r--core/css/jquery.ocdialog.scss14
-rw-r--r--core/js/js.js42
-rw-r--r--core/js/oc-dialogs.js2
-rw-r--r--settings/js/apps.js15
4 files changed, 56 insertions, 17 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);
diff --git a/settings/js/apps.js b/settings/js/apps.js
index 05514a10de2..4fca8539563 100644
--- a/settings/js/apps.js
+++ b/settings/js/apps.js
@@ -324,7 +324,10 @@ OC.Settings.Apps = OC.Settings.Apps || {
enableAppBundle:function(bundleId, active, element, groups) {
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
- OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.enableAppBundle, this, bundleId, active, element, groups));
+ OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.enableAppBundle, this, bundleId, active, element, groups), {
+ text: t('settings', 'Installing apps requires you to confirm your password'),
+ confirm: t('settings', 'Install app bundle'),
+ });
return;
}
@@ -348,7 +351,10 @@ OC.Settings.Apps = OC.Settings.Apps || {
*/
enableApp:function(appId, active, groups) {
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
- OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.enableApp, this, appId, active, groups));
+ OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.enableApp, this, appId, active, groups), {
+ text: ( active ? t('settings', 'Disabling apps requires you to confirm your password') : t('settings', 'Enabling apps requires you to confirm your password') ),
+ confirm: ( active ? t('settings', 'Disable app') : t('settings', 'Enable app') ),
+ });
return;
}
@@ -577,7 +583,10 @@ OC.Settings.Apps = OC.Settings.Apps || {
uninstallApp:function(appId, element) {
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
- OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.uninstallApp, this, appId, element));
+ OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.uninstallApp, this, appId, element), {
+ text: t('settings', 'Uninstalling apps requires you to confirm your password'),
+ confirm: t('settings', 'Uninstall')
+ });
return;
}