mirror of https://github.com/xwiki-labs/cryptpad
Fix access modal issues after password change #1365
This commit is contained in:
parent
645926c2ef
commit
aad3669556
|
@ -1527,6 +1527,7 @@ define([
|
||||||
hash: newHash,
|
hash: newHash,
|
||||||
href: newHref,
|
href: newHref,
|
||||||
roHref: newRoHref,
|
roHref: newRoHref,
|
||||||
|
channel: newSecret.channel
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,7 +30,6 @@ define([
|
||||||
var metadataMgr = common.getMetadataMgr();
|
var metadataMgr = common.getMetadataMgr();
|
||||||
|
|
||||||
var priv = metadataMgr.getPrivateData();
|
var priv = metadataMgr.getPrivateData();
|
||||||
var channel = data.channel || priv.channel;
|
|
||||||
var owners = data.owners || [];
|
var owners = data.owners || [];
|
||||||
var pending_owners = data.pending_owners || [];
|
var pending_owners = data.pending_owners || [];
|
||||||
var teamOwner = data.teamId;
|
var teamOwner = data.teamId;
|
||||||
|
@ -105,7 +104,7 @@ define([
|
||||||
}).nThen(function (waitFor) {
|
}).nThen(function (waitFor) {
|
||||||
// Send the command
|
// Send the command
|
||||||
sframeChan.query('Q_SET_PAD_METADATA', {
|
sframeChan.query('Q_SET_PAD_METADATA', {
|
||||||
channel: channel,
|
channel: data.channel || priv.channel,
|
||||||
channels: otherChan,
|
channels: otherChan,
|
||||||
command: pending ? 'RM_PENDING_OWNERS' : 'RM_OWNERS',
|
command: pending ? 'RM_PENDING_OWNERS' : 'RM_OWNERS',
|
||||||
value: [ed],
|
value: [ed],
|
||||||
|
@ -127,7 +126,7 @@ define([
|
||||||
var friend = friends[curve];
|
var friend = friends[curve];
|
||||||
if (!friend) { return; }
|
if (!friend) { return; }
|
||||||
common.mailbox.sendTo("RM_OWNER", {
|
common.mailbox.sendTo("RM_OWNER", {
|
||||||
channel: channel,
|
channel: data.channel || priv.channel,
|
||||||
title: data.title || title,
|
title: data.title || title,
|
||||||
pending: pending
|
pending: pending
|
||||||
}, {
|
}, {
|
||||||
|
@ -265,7 +264,7 @@ define([
|
||||||
if (toAddTeams.length) {
|
if (toAddTeams.length) {
|
||||||
// Send the command
|
// Send the command
|
||||||
sframeChan.query('Q_SET_PAD_METADATA', {
|
sframeChan.query('Q_SET_PAD_METADATA', {
|
||||||
channel: channel,
|
channel: data.channel || priv.channel,
|
||||||
channels: otherChan,
|
channels: otherChan,
|
||||||
command: 'ADD_OWNERS',
|
command: 'ADD_OWNERS',
|
||||||
value: toAddTeams.map(function (obj) { return obj.edPublic; }),
|
value: toAddTeams.map(function (obj) { return obj.edPublic; }),
|
||||||
|
@ -301,7 +300,7 @@ define([
|
||||||
if (toAdd.length) {
|
if (toAdd.length) {
|
||||||
// Send the command
|
// Send the command
|
||||||
sframeChan.query('Q_SET_PAD_METADATA', {
|
sframeChan.query('Q_SET_PAD_METADATA', {
|
||||||
channel: channel,
|
channel: data.channel || priv.channel,
|
||||||
channels: otherChan,
|
channels: otherChan,
|
||||||
command: 'ADD_PENDING_OWNERS',
|
command: 'ADD_PENDING_OWNERS',
|
||||||
value: toAdd,
|
value: toAdd,
|
||||||
|
@ -322,7 +321,7 @@ define([
|
||||||
if (addMe) {
|
if (addMe) {
|
||||||
// Send the command
|
// Send the command
|
||||||
sframeChan.query('Q_SET_PAD_METADATA', {
|
sframeChan.query('Q_SET_PAD_METADATA', {
|
||||||
channel: channel,
|
channel: data.channel || priv.channel,
|
||||||
channels: otherChan,
|
channels: otherChan,
|
||||||
command: 'ADD_OWNERS',
|
command: 'ADD_OWNERS',
|
||||||
value: [priv.edPublic],
|
value: [priv.edPublic],
|
||||||
|
@ -352,7 +351,7 @@ define([
|
||||||
var friend = friends[curve];
|
var friend = friends[curve];
|
||||||
if (!friend) { return; }
|
if (!friend) { return; }
|
||||||
common.mailbox.sendTo("ADD_OWNER", {
|
common.mailbox.sendTo("ADD_OWNER", {
|
||||||
channel: channel,
|
channel: data.channel || priv.channel,
|
||||||
channels: otherChan,
|
channels: otherChan,
|
||||||
href: href,
|
href: href,
|
||||||
calendar: opts.calendar,
|
calendar: opts.calendar,
|
||||||
|
@ -427,7 +426,6 @@ define([
|
||||||
var metadataMgr = common.getMetadataMgr();
|
var metadataMgr = common.getMetadataMgr();
|
||||||
|
|
||||||
var priv = metadataMgr.getPrivateData();
|
var priv = metadataMgr.getPrivateData();
|
||||||
var channel = data.channel || priv.channel;
|
|
||||||
var owners = data.owners || [];
|
var owners = data.owners || [];
|
||||||
var restricted = data.restricted || false;
|
var restricted = data.restricted || false;
|
||||||
var allowed = data.allowed || [];
|
var allowed = data.allowed || [];
|
||||||
|
@ -516,7 +514,7 @@ define([
|
||||||
*/
|
*/
|
||||||
// Send the command
|
// Send the command
|
||||||
sframeChan.query('Q_SET_PAD_METADATA', {
|
sframeChan.query('Q_SET_PAD_METADATA', {
|
||||||
channel: channel,
|
channel: data.channel || priv.channel,
|
||||||
channels: otherChan,
|
channels: otherChan,
|
||||||
command: 'RM_ALLOWED',
|
command: 'RM_ALLOWED',
|
||||||
value: [ed],
|
value: [ed],
|
||||||
|
@ -546,7 +544,7 @@ define([
|
||||||
spinner.spin();
|
spinner.spin();
|
||||||
var val = $checkbox.is(':checked');
|
var val = $checkbox.is(':checked');
|
||||||
sframeChan.query('Q_SET_PAD_METADATA', {
|
sframeChan.query('Q_SET_PAD_METADATA', {
|
||||||
channel: channel,
|
channel: data.channel || priv.channel,
|
||||||
channels: otherChan,
|
channels: otherChan,
|
||||||
command: 'RESTRICT_ACCESS',
|
command: 'RESTRICT_ACCESS',
|
||||||
value: [Boolean(val)],
|
value: [Boolean(val)],
|
||||||
|
@ -682,7 +680,7 @@ define([
|
||||||
if (toAdd.length) {
|
if (toAdd.length) {
|
||||||
// Send the command
|
// Send the command
|
||||||
sframeChan.query('Q_SET_PAD_METADATA', {
|
sframeChan.query('Q_SET_PAD_METADATA', {
|
||||||
channel: channel,
|
channel: data.channel || priv.channel,
|
||||||
channels: otherChan,
|
channels: otherChan,
|
||||||
command: 'ADD_ALLOWED',
|
command: 'ADD_ALLOWED',
|
||||||
value: toAdd,
|
value: toAdd,
|
||||||
|
@ -939,12 +937,12 @@ define([
|
||||||
sframeChan.query(q, {
|
sframeChan.query(q, {
|
||||||
teamId: typeof(owned) !== "boolean" ? owned : undefined,
|
teamId: typeof(owned) !== "boolean" ? owned : undefined,
|
||||||
href: href,
|
href: href,
|
||||||
oldPassword: priv.password,
|
oldPassword: data.password || priv.password,
|
||||||
password: newPass
|
password: newPass
|
||||||
}, function (err, data) {
|
}, function (err, res) {
|
||||||
$(passwordOk).text(Messages.properties_changePasswordButton);
|
$(passwordOk).text(Messages.properties_changePasswordButton);
|
||||||
pLocked = false;
|
pLocked = false;
|
||||||
err = err || data.error;
|
err = err || res.error;
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err === "PASSWORD_ALREADY_USED") {
|
if (err === "PASSWORD_ALREADY_USED") {
|
||||||
return void UI.alert(Messages.access_passwordUsed);
|
return void UI.alert(Messages.access_passwordUsed);
|
||||||
|
@ -954,6 +952,11 @@ define([
|
||||||
}
|
}
|
||||||
UI.findOKButton().click();
|
UI.findOKButton().click();
|
||||||
|
|
||||||
|
data.password = newPass;
|
||||||
|
data.href = res.href;
|
||||||
|
data.roHref = res.roHref;
|
||||||
|
data.channel = res.channel;
|
||||||
|
|
||||||
$pwInput.val(newPass);
|
$pwInput.val(newPass);
|
||||||
if (newPass) {
|
if (newPass) {
|
||||||
$password.show();
|
$password.show();
|
||||||
|
@ -969,7 +972,7 @@ define([
|
||||||
if (isFile || priv.app !== parsed.type) {
|
if (isFile || priv.app !== parsed.type) {
|
||||||
if (onProgress && onProgress.stop) { onProgress.stop(); }
|
if (onProgress && onProgress.stop) { onProgress.stop(); }
|
||||||
$(passwordOk).text(Messages.properties_changePasswordButton);
|
$(passwordOk).text(Messages.properties_changePasswordButton);
|
||||||
var alertMsg = data.warning ? Messages.properties_passwordWarningFile
|
var alertMsg = res.warning ? Messages.properties_passwordWarningFile
|
||||||
: Messages.properties_passwordSuccessFile;
|
: Messages.properties_passwordSuccessFile;
|
||||||
return void UI.alert(alertMsg, undefined, {force: true});
|
return void UI.alert(alertMsg, undefined, {force: true});
|
||||||
}
|
}
|
||||||
|
@ -978,7 +981,7 @@ define([
|
||||||
// Use hidden hash if needed (we're an owner of this pad so we know it is stored)
|
// 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 useUnsafe = Util.find(priv, ['settings', 'security', 'unsafeLinks']);
|
||||||
if (isNotStored) { useUnsafe = true; }
|
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) {
|
if (useUnsafe !== true) {
|
||||||
var newParsed = Hash.parsePadUrl(_href);
|
var newParsed = Hash.parsePadUrl(_href);
|
||||||
var newSecret = Hash.getSecrets(newParsed.type, newParsed.hash, newPass);
|
var newSecret = Hash.getSecrets(newParsed.type, newParsed.hash, newPass);
|
||||||
|
@ -989,7 +992,7 @@ define([
|
||||||
// Trigger a page reload if the href didn't change
|
// Trigger a page reload if the href didn't change
|
||||||
if (_href === href) { _href = undefined; }
|
if (_href === href) { _href = undefined; }
|
||||||
|
|
||||||
if (data.warning) {
|
if (res.warning) {
|
||||||
return void UI.alert(Messages.properties_passwordWarning, function () {
|
return void UI.alert(Messages.properties_passwordWarning, function () {
|
||||||
if (isNotStored) {
|
if (isNotStored) {
|
||||||
return sframeChan.query('Q_PASSWORD_CHECK', newPass, () => { common.gotoURL(_href); });
|
return sframeChan.query('Q_PASSWORD_CHECK', newPass, () => { common.gotoURL(_href); });
|
||||||
|
|
Loading…
Reference in New Issue