Merge pull request #1394 from cryptpad/password_change_access

Fix access modal issues after password change
This commit is contained in:
yflory 2024-01-29 17:30:48 +01:00 committed by GitHub
commit 06c47a7750
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 17 deletions

View File

@ -1527,6 +1527,7 @@ define([
hash: newHash,
href: newHref,
roHref: newRoHref,
channel: newSecret.channel
});
});
};

View File

@ -30,7 +30,6 @@ define([
var metadataMgr = common.getMetadataMgr();
var priv = metadataMgr.getPrivateData();
var channel = data.channel || priv.channel;
var owners = data.owners || [];
var pending_owners = data.pending_owners || [];
var teamOwner = data.teamId;
@ -105,7 +104,7 @@ define([
}).nThen(function (waitFor) {
// Send the command
sframeChan.query('Q_SET_PAD_METADATA', {
channel: channel,
channel: data.channel || priv.channel,
channels: otherChan,
command: pending ? 'RM_PENDING_OWNERS' : 'RM_OWNERS',
value: [ed],
@ -127,7 +126,7 @@ define([
var friend = friends[curve];
if (!friend) { return; }
common.mailbox.sendTo("RM_OWNER", {
channel: channel,
channel: data.channel || priv.channel,
title: data.title || title,
pending: pending
}, {
@ -265,7 +264,7 @@ define([
if (toAddTeams.length) {
// Send the command
sframeChan.query('Q_SET_PAD_METADATA', {
channel: channel,
channel: data.channel || priv.channel,
channels: otherChan,
command: 'ADD_OWNERS',
value: toAddTeams.map(function (obj) { return obj.edPublic; }),
@ -301,7 +300,7 @@ define([
if (toAdd.length) {
// Send the command
sframeChan.query('Q_SET_PAD_METADATA', {
channel: channel,
channel: data.channel || priv.channel,
channels: otherChan,
command: 'ADD_PENDING_OWNERS',
value: toAdd,
@ -322,7 +321,7 @@ define([
if (addMe) {
// Send the command
sframeChan.query('Q_SET_PAD_METADATA', {
channel: channel,
channel: data.channel || priv.channel,
channels: otherChan,
command: 'ADD_OWNERS',
value: [priv.edPublic],
@ -352,7 +351,7 @@ define([
var friend = friends[curve];
if (!friend) { return; }
common.mailbox.sendTo("ADD_OWNER", {
channel: channel,
channel: data.channel || priv.channel,
channels: otherChan,
href: href,
calendar: opts.calendar,
@ -427,7 +426,6 @@ define([
var metadataMgr = common.getMetadataMgr();
var priv = metadataMgr.getPrivateData();
var channel = data.channel || priv.channel;
var owners = data.owners || [];
var restricted = data.restricted || false;
var allowed = data.allowed || [];
@ -516,7 +514,7 @@ define([
*/
// Send the command
sframeChan.query('Q_SET_PAD_METADATA', {
channel: channel,
channel: data.channel || priv.channel,
channels: otherChan,
command: 'RM_ALLOWED',
value: [ed],
@ -546,7 +544,7 @@ define([
spinner.spin();
var val = $checkbox.is(':checked');
sframeChan.query('Q_SET_PAD_METADATA', {
channel: channel,
channel: data.channel || priv.channel,
channels: otherChan,
command: 'RESTRICT_ACCESS',
value: [Boolean(val)],
@ -683,7 +681,7 @@ define([
if (toAdd.length) {
// Send the command
sframeChan.query('Q_SET_PAD_METADATA', {
channel: channel,
channel: data.channel || priv.channel,
channels: otherChan,
command: 'ADD_ALLOWED',
value: toAdd,
@ -953,12 +951,12 @@ define([
sframeChan.query(q, {
teamId: typeof(owned) !== "boolean" ? owned : undefined,
href: href,
oldPassword: priv.password,
oldPassword: data.password || priv.password,
password: newPass
}, function (err, data) {
}, function (err, res) {
$(passwordOk).text(Messages.properties_changePasswordButton);
pLocked = false;
err = err || data.error;
err = err || res.error;
if (err) {
if (err === "PASSWORD_ALREADY_USED") {
return void UI.alert(Messages.access_passwordUsed);
@ -968,6 +966,11 @@ define([
}
UI.findOKButton().click();
data.password = newPass;
data.href = res.href;
data.roHref = res.roHref;
data.channel = res.channel;
$pwInput.val(newPass);
if (newPass) {
$password.show();
@ -983,7 +986,7 @@ define([
if (isFile || priv.app !== parsed.type) {
if (onProgress && onProgress.stop) { onProgress.stop(); }
$(passwordOk).text(Messages.properties_changePasswordButton);
var alertMsg = data.warning ? Messages.properties_passwordWarningFile
var alertMsg = res.warning ? Messages.properties_passwordWarningFile
: Messages.properties_passwordSuccessFile;
return void UI.alert(alertMsg, undefined, {force: true});
}
@ -992,7 +995,7 @@ define([
// 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']);
if (isNotStored) { useUnsafe = true; }
var _href = (priv.readOnly && data.roHref) ? data.roHref : data.href;
var _href = (priv.readOnly && res.roHref) ? res.roHref : res.href;
if (useUnsafe !== true) {
var newParsed = Hash.parsePadUrl(_href);
var newSecret = Hash.getSecrets(newParsed.type, newParsed.hash, newPass);
@ -1003,7 +1006,7 @@ define([
// Trigger a page reload if the href didn't change
if (_href === href) { _href = undefined; }
if (data.warning) {
if (res.warning) {
return void UI.alert(Messages.properties_passwordWarning, function () {
if (isNotStored) {
return sframeChan.query('Q_PASSWORD_CHECK', newPass, () => { common.gotoURL(_href); });