mirror of https://github.com/xwiki-labs/cryptpad
Fix password change issues with read-only pads or from the drive
This commit is contained in:
parent
086e500b8e
commit
12a45377e7
|
@ -547,21 +547,27 @@ define([
|
|||
|
||||
if (!data.noPassword) {
|
||||
var hasPassword = data.password;
|
||||
var $pwLabel = $('<label>', {'for': 'cp-app-prop-password'}).text(Messages.creation_passwordValue)
|
||||
.hide().appendTo($d);
|
||||
var password = UI.passwordInput({
|
||||
id: 'cp-app-prop-password',
|
||||
readonly: 'readonly'
|
||||
});
|
||||
var $password = $(password).hide();
|
||||
var $pwInput = $password.find('.cp-password-input');
|
||||
$pwInput.val(data.password).click(function () {
|
||||
$pwInput[0].select();
|
||||
});
|
||||
$d.append(password);
|
||||
|
||||
if (hasPassword) {
|
||||
$('<label>', {'for': 'cp-app-prop-password'}).text(Messages.creation_passwordValue)
|
||||
.appendTo($d);
|
||||
var password = UI.passwordInput({
|
||||
id: 'cp-app-prop-password',
|
||||
readonly: 'readonly'
|
||||
});
|
||||
var $pwInput = $(password).find('.cp-password-input');
|
||||
$pwInput.val(data.password).click(function () {
|
||||
$pwInput[0].select();
|
||||
});
|
||||
$d.append(password);
|
||||
$pwLabel.show();
|
||||
$password.css('display', 'flex');
|
||||
}
|
||||
|
||||
if (!data.noEditPassword && owned) { // FIXME SHEET fix password change for sheets
|
||||
// In the properties, we should have the edit href if we know it.
|
||||
// We should know it because the pad is stored, but it's better to check...
|
||||
if (!data.noEditPassword && owned && data.href) { // FIXME SHEET fix password change for sheets
|
||||
var sframeChan = common.getSframeChannel();
|
||||
|
||||
var isOO = parsed.type === 'sheet';
|
||||
|
@ -621,7 +627,7 @@ define([
|
|||
|
||||
sframeChan.query(q, {
|
||||
teamId: typeof(owned) !== "boolean" ? owned : undefined,
|
||||
href: data.href || data.roHref,
|
||||
href: data.href,
|
||||
password: newPass
|
||||
}, function (err, data) {
|
||||
$(passwordOk).text(Messages.properties_changePasswordButton);
|
||||
|
@ -631,8 +637,16 @@ define([
|
|||
return void UI.alert(Messages.properties_passwordError);
|
||||
}
|
||||
UI.findOKButton().click();
|
||||
if (isFile) {
|
||||
onProgress.stop();
|
||||
|
||||
$pwLabel.show();
|
||||
$password.css('display', 'flex');
|
||||
$pwInput.val(newPass);
|
||||
|
||||
// If the current document is a file or if we're changing the password from a drive,
|
||||
// we don't have to reload the page at the end.
|
||||
// Tell the user the password change was successful and abort
|
||||
if (isFile || priv.app !== parsed.type) {
|
||||
if (onProgress && onProgress.stop) { onProgress.stop(); }
|
||||
$(passwordOk).text(Messages.properties_changePasswordButton);
|
||||
var alertMsg = data.warning ? Messages.properties_passwordWarningFile
|
||||
: Messages.properties_passwordSuccessFile;
|
||||
|
@ -642,7 +656,7 @@ define([
|
|||
// Pad password changed: update the href
|
||||
// Use hidden hash if needed (we're an owner of this pad so we know it is stored)
|
||||
var useUnsafe = Util.find(priv, ['settings', 'security', 'unsafeLinks']);
|
||||
var href = data.href || data.roHref;
|
||||
var href = (priv.readOnly && data.roHref) ? data.roHref : data.href;
|
||||
if (!useUnsafe) {
|
||||
var newParsed = Hash.parsePadUrl(href);
|
||||
var newSecret = Hash.getSecrets(newParsed.type, newParsed.hash, newPass);
|
||||
|
|
|
@ -1037,6 +1037,7 @@ define([
|
|||
}, waitFor());
|
||||
}
|
||||
}).nThen(function () {
|
||||
common.drive.onChange.fire({path: ['drive', Constants.storageKey]});
|
||||
cb({
|
||||
warning: warning,
|
||||
hash: newHash,
|
||||
|
@ -1170,6 +1171,7 @@ define([
|
|||
channel: newSecret.channel
|
||||
}, waitFor());
|
||||
}).nThen(function () {
|
||||
common.drive.onChange.fire({path: ['drive', Constants.storageKey]});
|
||||
cb({
|
||||
warning: warning,
|
||||
hash: newHash,
|
||||
|
@ -1404,6 +1406,7 @@ define([
|
|||
}, waitFor());
|
||||
}));
|
||||
}).nThen(function () {
|
||||
common.drive.onChange.fire({path: ['drive', Constants.storageKey]});
|
||||
cb({
|
||||
warning: warning,
|
||||
hash: newHash,
|
||||
|
|
|
@ -1125,12 +1125,12 @@ define([
|
|||
});
|
||||
|
||||
sframeChan.on('Q_OO_PASSWORD_CHANGE', function (data, cb) {
|
||||
data.href = data.href || currentPad.href;
|
||||
data.href = data.href;
|
||||
Cryptpad.changeOOPassword(data, cb);
|
||||
});
|
||||
|
||||
sframeChan.on('Q_PAD_PASSWORD_CHANGE', function (data, cb) {
|
||||
data.href = data.href || currentPad.href;
|
||||
data.href = data.href;
|
||||
Cryptpad.changePadPassword(Cryptget, Crypto, data, cb);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue