mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2025-08-02 03:26:06 -04:00
Add password retry feature
This commit is contained in:
parent
183ebe518b
commit
d53207e404
5 changed files with 91 additions and 11 deletions
|
@ -460,7 +460,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
// file is loaded
|
||||
}
|
||||
|
||||
// for all other langauges than English for which this behaviour
|
||||
// for all other languages than English for which this behaviour
|
||||
// is expected as it is built-in, log error
|
||||
if (language !== null && language !== 'en') {
|
||||
console.error('Missing translation for: \'' + messageId + '\' in language ' + language);
|
||||
|
@ -1533,6 +1533,21 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* resets the password to an empty string
|
||||
*
|
||||
* @name Prompt.reset
|
||||
* @function
|
||||
*/
|
||||
me.reset = function()
|
||||
{
|
||||
// reset internal
|
||||
password = '';
|
||||
|
||||
// and also reset UI
|
||||
$passwordDecrypt.val('');
|
||||
}
|
||||
|
||||
/**
|
||||
* init status manager
|
||||
*
|
||||
|
@ -2510,9 +2525,11 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
$password,
|
||||
$passwordInput,
|
||||
$rawTextButton,
|
||||
$sendButton;
|
||||
$sendButton,
|
||||
$retryButton;
|
||||
|
||||
var pasteExpiration = '1week';
|
||||
var pasteExpiration = '1week',
|
||||
retryButtonCallback;
|
||||
|
||||
/**
|
||||
* set the expiration on bootstrap templates in dropdown
|
||||
|
@ -2663,6 +2680,19 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
Controller.newPaste();
|
||||
}
|
||||
|
||||
/**
|
||||
* retrys some callback registered before
|
||||
*
|
||||
* @name TopNav.clickRetryButton
|
||||
* @private
|
||||
* @function
|
||||
* @param {Event} event
|
||||
*/
|
||||
function clickRetryButton(event)
|
||||
{
|
||||
retryButtonCallback();
|
||||
}
|
||||
|
||||
/**
|
||||
* removes the existing attachment
|
||||
*
|
||||
|
@ -2720,8 +2750,8 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
return;
|
||||
}
|
||||
|
||||
$newButton.addClass('hidden');
|
||||
$cloneButton.addClass('hidden');
|
||||
$newButton.addClass('hidden');
|
||||
$rawTextButton.addClass('hidden');
|
||||
|
||||
viewButtonsDisplayed = false;
|
||||
|
@ -2752,14 +2782,14 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
return;
|
||||
}
|
||||
|
||||
$sendButton.removeClass('hidden');
|
||||
$attach.removeClass('hidden');
|
||||
$burnAfterReadingOption.removeClass('hidden');
|
||||
$expiration.removeClass('hidden');
|
||||
$formatter.removeClass('hidden');
|
||||
$burnAfterReadingOption.removeClass('hidden');
|
||||
$openDiscussionOption.removeClass('hidden');
|
||||
$newButton.removeClass('hidden');
|
||||
$openDiscussionOption.removeClass('hidden');
|
||||
$password.removeClass('hidden');
|
||||
$attach.removeClass('hidden');
|
||||
$sendButton.removeClass('hidden');
|
||||
|
||||
createButtonsDisplayed = true;
|
||||
}
|
||||
|
@ -2800,6 +2830,28 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
$newButton.removeClass('hidden');
|
||||
}
|
||||
|
||||
/**
|
||||
* only shows the "retry" button
|
||||
*
|
||||
* @name TopNav.showRetryButton
|
||||
* @function
|
||||
*/
|
||||
me.showRetryButton = function()
|
||||
{
|
||||
$retryButton.removeClass('hidden');
|
||||
}
|
||||
|
||||
/**
|
||||
* hides the "retry" button
|
||||
*
|
||||
* @name TopNav.hideRetryButton
|
||||
* @function
|
||||
*/
|
||||
me.hideRetryButton = function()
|
||||
{
|
||||
$retryButton.addClass('hidden');
|
||||
}
|
||||
|
||||
/**
|
||||
* only hides the clone button
|
||||
*
|
||||
|
@ -2947,6 +2999,18 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
return $customAttachment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function to call when the retry button is clicked.
|
||||
*
|
||||
* @name TopNav.setRetryCallback
|
||||
* @function
|
||||
* @param {function} callback
|
||||
*/
|
||||
me.setRetryCallback = function(callback)
|
||||
{
|
||||
retryButtonCallback = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* init navigation manager
|
||||
*
|
||||
|
@ -2972,6 +3036,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
$password = $('#password');
|
||||
$passwordInput = $('#passwordinput');
|
||||
$rawTextButton = $('#rawtextbutton');
|
||||
$retryButton = $('#retrybutton');
|
||||
$sendButton = $('#sendbutton');
|
||||
|
||||
// bootstrap template drop down
|
||||
|
@ -2986,6 +3051,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
$sendButton.click(PasteEncrypter.sendPaste);
|
||||
$cloneButton.click(Controller.clonePaste);
|
||||
$rawTextButton.click(rawText);
|
||||
$retryButton.click(clickRetryButton);
|
||||
$fileRemoveButton.click(removeAttachment);
|
||||
|
||||
// bootstrap template drop downs
|
||||
|
@ -3796,6 +3862,9 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
*/
|
||||
me.run = function(paste)
|
||||
{
|
||||
// in case the button has been there previously
|
||||
TopNav.hideRetryButton();
|
||||
|
||||
Alert.hideMessages();
|
||||
Alert.showLoading('Decrypting paste…', 0, 'cloud-download'); // @TODO icon maybe rotation-lock, but needs full Glyphicons
|
||||
|
||||
|
@ -3845,7 +3914,11 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
|
||||
// log and show error
|
||||
console.error(err);
|
||||
Alert.showError('Could not decrypt data (Wrong key?)');
|
||||
Alert.showError('Could not decrypt data. Did you enter a wrong password? Retry with the button at the top.');
|
||||
// reset password, so it can be re-entered and sow retry button
|
||||
Prompt.reset();
|
||||
TopNav.setRetryCallback(me.run);
|
||||
TopNav.showRetryButton();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue