Display the prefilled password page when receiving a password-protected pad
This commit is contained in:
parent
62504e0e32
commit
3bdca60c76
@ -3463,19 +3463,24 @@ define([
|
|||||||
(cb || function () {})();
|
(cb || function () {})();
|
||||||
};
|
};
|
||||||
|
|
||||||
UIElements.displayPasswordPrompt = function (common, isError) {
|
UIElements.displayPasswordPrompt = function (common, cfg, isError) {
|
||||||
var error;
|
var error;
|
||||||
if (isError) { error = setHTML(h('p.cp-password-error'), Messages.password_error); }
|
if (isError) { error = setHTML(h('p.cp-password-error'), Messages.password_error); }
|
||||||
var info = h('p.cp-password-info', Messages.password_info);
|
var info = h('p.cp-password-info', Messages.password_info);
|
||||||
var password = UI.passwordInput({placeholder: Messages.password_placeholder});
|
var password = UI.passwordInput({placeholder: Messages.password_placeholder});
|
||||||
var button = h('button', Messages.password_submit);
|
var button = h('button', Messages.password_submit);
|
||||||
|
cfg = cfg || {};
|
||||||
|
|
||||||
|
if (cfg.value && !isError) {
|
||||||
|
$(password).find('.cp-password-input').val(cfg.value);
|
||||||
|
}
|
||||||
|
|
||||||
var submit = function () {
|
var submit = function () {
|
||||||
var value = $(password).find('.cp-password-input').val();
|
var value = $(password).find('.cp-password-input').val();
|
||||||
UI.addLoadingScreen();
|
UI.addLoadingScreen();
|
||||||
common.getSframeChannel().query('Q_PAD_PASSWORD_VALUE', value, function (err, data) {
|
common.getSframeChannel().query('Q_PAD_PASSWORD_VALUE', value, function (err, data) {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
UIElements.displayPasswordPrompt(common, true);
|
UIElements.displayPasswordPrompt(common, cfg, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -206,7 +206,7 @@ define([
|
|||||||
// 2c: 'view' pad and '/p/' and a wrong password stored --> the seed is incorrect
|
// 2c: 'view' pad and '/p/' and a wrong password stored --> the seed is incorrect
|
||||||
// 2d: 'view' pad and '/p/' and password never stored (security feature) --> password-prompt
|
// 2d: 'view' pad and '/p/' and password never stored (security feature) --> password-prompt
|
||||||
|
|
||||||
var askPassword = function (wrongPasswordStored) {
|
var askPassword = function (wrongPasswordStored, cfg) {
|
||||||
// Ask for the password and check if the pad exists
|
// Ask for the password and check if the pad exists
|
||||||
// If the pad doesn't exist, it means the password isn't correct
|
// If the pad doesn't exist, it means the password isn't correct
|
||||||
// or the pad has been deleted
|
// or the pad has been deleted
|
||||||
@ -250,11 +250,14 @@ define([
|
|||||||
// Not a file, so we can use `isNewChannel`
|
// Not a file, so we can use `isNewChannel`
|
||||||
Cryptpad.isNewChannel(window.location.href, password, next);
|
Cryptpad.isNewChannel(window.location.href, password, next);
|
||||||
});
|
});
|
||||||
sframeChan.event("EV_PAD_PASSWORD");
|
sframeChan.event("EV_PAD_PASSWORD", cfg);
|
||||||
};
|
};
|
||||||
|
|
||||||
var done = waitFor();
|
var done = waitFor();
|
||||||
var stored = false;
|
var stored = false;
|
||||||
|
var passwordCfg = {
|
||||||
|
value: ''
|
||||||
|
};
|
||||||
nThen(function (w) {
|
nThen(function (w) {
|
||||||
Cryptpad.getPadAttribute('title', w(function (err, data) {
|
Cryptpad.getPadAttribute('title', w(function (err, data) {
|
||||||
stored = (!err && typeof (data) === "string");
|
stored = (!err && typeof (data) === "string");
|
||||||
@ -264,7 +267,7 @@ define([
|
|||||||
}), parsed.getUrl());
|
}), parsed.getUrl());
|
||||||
}).nThen(function (w) {
|
}).nThen(function (w) {
|
||||||
if (!password && !stored && sessionStorage.newPadPassword) {
|
if (!password && !stored && sessionStorage.newPadPassword) {
|
||||||
password = sessionStorage.newPadPassword;
|
passwordCfg.value = sessionStorage.newPadPassword;
|
||||||
delete sessionStorage.newPadPassword;
|
delete sessionStorage.newPadPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,7 +277,7 @@ define([
|
|||||||
Cryptpad.getFileSize(window.location.href, password, w(function (e, size) {
|
Cryptpad.getFileSize(window.location.href, password, w(function (e, size) {
|
||||||
if (size !== 0) { return void todo(); }
|
if (size !== 0) { return void todo(); }
|
||||||
// Wrong password or deleted file?
|
// Wrong password or deleted file?
|
||||||
askPassword(true);
|
askPassword(true, passwordCfg);
|
||||||
}));
|
}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -293,7 +296,7 @@ define([
|
|||||||
return void todo();
|
return void todo();
|
||||||
}
|
}
|
||||||
// Wrong password or deleted file?
|
// Wrong password or deleted file?
|
||||||
askPassword(true);
|
askPassword(true, passwordCfg);
|
||||||
}));
|
}));
|
||||||
}).nThen(done);
|
}).nThen(done);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -595,8 +595,8 @@ define([
|
|||||||
|
|
||||||
UI.addTooltips();
|
UI.addTooltips();
|
||||||
|
|
||||||
ctx.sframeChan.on("EV_PAD_PASSWORD", function () {
|
ctx.sframeChan.on("EV_PAD_PASSWORD", function (cfg) {
|
||||||
UIElements.displayPasswordPrompt(funcs);
|
UIElements.displayPasswordPrompt(funcs, cfg);
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.sframeChan.on("EV_PAD_PASSWORD_ERROR", function () {
|
ctx.sframeChan.on("EV_PAD_PASSWORD_ERROR", function () {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user