Fix pad password change not reloading with the correct URL
This commit is contained in:
@@ -147,7 +147,7 @@ define([
|
||||
id: 'cp-app-prop-expire',
|
||||
}));
|
||||
|
||||
var hasPassword = typeof data.password !== "undefined";
|
||||
var hasPassword = data.password;
|
||||
if (hasPassword) {
|
||||
$('<label>', {'for': 'cp-app-prop-password'}).text(Messages.creation_passwordValue)
|
||||
.appendTo($d);
|
||||
@@ -183,23 +183,31 @@ define([
|
||||
passwordOk
|
||||
]);
|
||||
$(passwordOk).click(function () {
|
||||
var newPass = $(newPassword).find('input').val();
|
||||
if (data.password === newPass ||
|
||||
(!data.password && !newPass)) {
|
||||
return void UI.alert(Messages.properties_passwordSame);
|
||||
}
|
||||
UI.confirm(changePwConfirm, function (yes) {
|
||||
if (!yes) { return; }
|
||||
sframeChan.query("Q_PAD_PASSWORD_CHANGE", {
|
||||
href: data.href,
|
||||
password: $(newPassword).find('input').val()
|
||||
password: newPass
|
||||
}, function (err, data) {
|
||||
if (err || data.error) {
|
||||
return void UI.alert(Messages.properties_passwordError);
|
||||
}
|
||||
UI.findOKButton().click();
|
||||
// If we didn't have a password, we have to add the /p/
|
||||
// If we had a password and we changed it to a new one, we just have to reload
|
||||
// If we had a password and we removed it, we have to remove the /p/
|
||||
if (data.warning) {
|
||||
return void UI.alert(Messages.properties_passwordWarning, function () {
|
||||
common.gotoURL(hasPassword ? undefined : data.href);
|
||||
common.gotoURL(hasPassword && newPass ? undefined : data.href);
|
||||
}, {force: true});
|
||||
}
|
||||
return void UI.alert(Messages.properties_passwordSuccess, function () {
|
||||
common.gotoURL(hasPassword ? undefined : data.href);
|
||||
common.gotoURL(hasPassword && newPass ? undefined : data.href);
|
||||
}, {force: true});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -622,10 +622,17 @@ define([
|
||||
var warning = false;
|
||||
var newHash;
|
||||
var oldChannel;
|
||||
if (parsed.hashData.password) {
|
||||
newHash = parsed.hash;
|
||||
var newSecret;
|
||||
|
||||
if (parsed.hashData.version >= 2) {
|
||||
newSecret = Hash.getSecrets(parsed.type, parsed.hash, newPassword);
|
||||
if (!(newSecret.keys && newSecret.keys.editKeyStr)) {
|
||||
return void cb({error: 'EAUTH'});
|
||||
}
|
||||
newHash = Hash.getEditHashFromKeys(newSecret);
|
||||
} else {
|
||||
newHash = Hash.createRandomHash(parsed.type, newPassword);
|
||||
newSecret = Hash.getSecrets(parsed.type, newHash, newPassword);
|
||||
}
|
||||
var newHref = '/' + parsed.type + '/#' + newHash;
|
||||
|
||||
@@ -677,16 +684,17 @@ define([
|
||||
return void cb(obj);
|
||||
}
|
||||
}));
|
||||
common.unpinPads([oldChannel], waitFor());
|
||||
common.pinPads([newSecret.channel], waitFor());
|
||||
}).nThen(function (waitFor) {
|
||||
common.setPadAttribute('password', newPassword, waitFor(function (err) {
|
||||
if (err) { warning = true; }
|
||||
}), href);
|
||||
var secret = Hash.getSecrets(parsed.type, newHash, newPassword);
|
||||
common.setPadAttribute('channel', secret.channel, waitFor(function (err) {
|
||||
common.setPadAttribute('channel', newSecret.channel, waitFor(function (err) {
|
||||
if (err) { warning = true; }
|
||||
}), href);
|
||||
|
||||
if (parsed.hashData.password) { return; } // same hash
|
||||
if (parsed.hashData.password && newPassword) { return; } // same hash
|
||||
common.setPadAttribute('href', newHref, waitFor(function (err) {
|
||||
if (err) { warning = true; }
|
||||
}), href);
|
||||
|
||||
Reference in New Issue
Block a user