Add password retry feature
This commit is contained in:
parent
183ebe518b
commit
d53207e404
@ -460,7 +460,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||||||
// file is loaded
|
// 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
|
// is expected as it is built-in, log error
|
||||||
if (language !== null && language !== 'en') {
|
if (language !== null && language !== 'en') {
|
||||||
console.error('Missing translation for: \'' + messageId + '\' in language ' + language);
|
console.error('Missing translation for: \'' + messageId + '\' in language ' + language);
|
||||||
@ -1533,6 +1533,21 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||||||
return password;
|
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
|
* init status manager
|
||||||
*
|
*
|
||||||
@ -2510,9 +2525,11 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||||||
$password,
|
$password,
|
||||||
$passwordInput,
|
$passwordInput,
|
||||||
$rawTextButton,
|
$rawTextButton,
|
||||||
$sendButton;
|
$sendButton,
|
||||||
|
$retryButton;
|
||||||
|
|
||||||
var pasteExpiration = '1week';
|
var pasteExpiration = '1week',
|
||||||
|
retryButtonCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the expiration on bootstrap templates in dropdown
|
* set the expiration on bootstrap templates in dropdown
|
||||||
@ -2663,6 +2680,19 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||||||
Controller.newPaste();
|
Controller.newPaste();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* retrys some callback registered before
|
||||||
|
*
|
||||||
|
* @name TopNav.clickRetryButton
|
||||||
|
* @private
|
||||||
|
* @function
|
||||||
|
* @param {Event} event
|
||||||
|
*/
|
||||||
|
function clickRetryButton(event)
|
||||||
|
{
|
||||||
|
retryButtonCallback();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* removes the existing attachment
|
* removes the existing attachment
|
||||||
*
|
*
|
||||||
@ -2720,8 +2750,8 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$newButton.addClass('hidden');
|
|
||||||
$cloneButton.addClass('hidden');
|
$cloneButton.addClass('hidden');
|
||||||
|
$newButton.addClass('hidden');
|
||||||
$rawTextButton.addClass('hidden');
|
$rawTextButton.addClass('hidden');
|
||||||
|
|
||||||
viewButtonsDisplayed = false;
|
viewButtonsDisplayed = false;
|
||||||
@ -2752,14 +2782,14 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sendButton.removeClass('hidden');
|
$attach.removeClass('hidden');
|
||||||
|
$burnAfterReadingOption.removeClass('hidden');
|
||||||
$expiration.removeClass('hidden');
|
$expiration.removeClass('hidden');
|
||||||
$formatter.removeClass('hidden');
|
$formatter.removeClass('hidden');
|
||||||
$burnAfterReadingOption.removeClass('hidden');
|
|
||||||
$openDiscussionOption.removeClass('hidden');
|
|
||||||
$newButton.removeClass('hidden');
|
$newButton.removeClass('hidden');
|
||||||
|
$openDiscussionOption.removeClass('hidden');
|
||||||
$password.removeClass('hidden');
|
$password.removeClass('hidden');
|
||||||
$attach.removeClass('hidden');
|
$sendButton.removeClass('hidden');
|
||||||
|
|
||||||
createButtonsDisplayed = true;
|
createButtonsDisplayed = true;
|
||||||
}
|
}
|
||||||
@ -2800,6 +2830,28 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||||||
$newButton.removeClass('hidden');
|
$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
|
* only hides the clone button
|
||||||
*
|
*
|
||||||
@ -2947,6 +2999,18 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||||||
return $customAttachment;
|
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
|
* init navigation manager
|
||||||
*
|
*
|
||||||
@ -2972,6 +3036,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||||||
$password = $('#password');
|
$password = $('#password');
|
||||||
$passwordInput = $('#passwordinput');
|
$passwordInput = $('#passwordinput');
|
||||||
$rawTextButton = $('#rawtextbutton');
|
$rawTextButton = $('#rawtextbutton');
|
||||||
|
$retryButton = $('#retrybutton');
|
||||||
$sendButton = $('#sendbutton');
|
$sendButton = $('#sendbutton');
|
||||||
|
|
||||||
// bootstrap template drop down
|
// bootstrap template drop down
|
||||||
@ -2986,6 +3051,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||||||
$sendButton.click(PasteEncrypter.sendPaste);
|
$sendButton.click(PasteEncrypter.sendPaste);
|
||||||
$cloneButton.click(Controller.clonePaste);
|
$cloneButton.click(Controller.clonePaste);
|
||||||
$rawTextButton.click(rawText);
|
$rawTextButton.click(rawText);
|
||||||
|
$retryButton.click(clickRetryButton);
|
||||||
$fileRemoveButton.click(removeAttachment);
|
$fileRemoveButton.click(removeAttachment);
|
||||||
|
|
||||||
// bootstrap template drop downs
|
// bootstrap template drop downs
|
||||||
@ -3796,6 +3862,9 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||||||
*/
|
*/
|
||||||
me.run = function(paste)
|
me.run = function(paste)
|
||||||
{
|
{
|
||||||
|
// in case the button has been there previously
|
||||||
|
TopNav.hideRetryButton();
|
||||||
|
|
||||||
Alert.hideMessages();
|
Alert.hideMessages();
|
||||||
Alert.showLoading('Decrypting paste…', 0, 'cloud-download'); // @TODO icon maybe rotation-lock, but needs full Glyphicons
|
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
|
// log and show error
|
||||||
console.error(err);
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ if ($MARKDOWN):
|
|||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-TCwmpH2nrRe3mLYIsGG90FGOFAqZal8SUQVNp16iA7K1B80I//RXp8mYxXdyyk/eluKilwCNY5wo9MYC4vdEoQ==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-tGE0CigbTPqWg1xkIeJrdAT3U9QsTTI2k/8qviRyBVbyuevBiyM3XBlmpARRjHwv075QSK4h4TuI8TlU9ScS2Q==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
@ -125,6 +125,11 @@ endif;
|
|||||||
<?php echo I18n::_('Loading…'), PHP_EOL; ?>
|
<?php echo I18n::_('Loading…'), PHP_EOL; ?>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
<button id="retrybutton" type="button" class="reloadlink hidden btn btn-<?php echo $isDark ? 'warning' : 'primary'; ?> navbar-btn">
|
||||||
|
<span class="glyphicon glyphicon-repeat" aria-hidden="true"></span> <?php echo I18n::_('Retry'), PHP_EOL; ?>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
<?php
|
<?php
|
||||||
if ($isPage):
|
if ($isPage):
|
||||||
?>
|
?>
|
||||||
|
@ -47,7 +47,7 @@ if ($MARKDOWN):
|
|||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-TCwmpH2nrRe3mLYIsGG90FGOFAqZal8SUQVNp16iA7K1B80I//RXp8mYxXdyyk/eluKilwCNY5wo9MYC4vdEoQ==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-tGE0CigbTPqWg1xkIeJrdAT3U9QsTTI2k/8qviRyBVbyuevBiyM3XBlmpARRjHwv075QSK4h4TuI8TlU9ScS2Q==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
@ -23,6 +23,7 @@ return array(
|
|||||||
'PrivateBin\\Model\\Comment' => $baseDir . '/lib/Model/Comment.php',
|
'PrivateBin\\Model\\Comment' => $baseDir . '/lib/Model/Comment.php',
|
||||||
'PrivateBin\\Model\\Paste' => $baseDir . '/lib/Model/Paste.php',
|
'PrivateBin\\Model\\Paste' => $baseDir . '/lib/Model/Paste.php',
|
||||||
'PrivateBin\\Persistence\\AbstractPersistence' => $baseDir . '/lib/Persistence/AbstractPersistence.php',
|
'PrivateBin\\Persistence\\AbstractPersistence' => $baseDir . '/lib/Persistence/AbstractPersistence.php',
|
||||||
|
'PrivateBin\\Persistence\\DataStore' => $baseDir . '/lib/Persistence/DataStore.php',
|
||||||
'PrivateBin\\Persistence\\PurgeLimiter' => $baseDir . '/lib/Persistence/PurgeLimiter.php',
|
'PrivateBin\\Persistence\\PurgeLimiter' => $baseDir . '/lib/Persistence/PurgeLimiter.php',
|
||||||
'PrivateBin\\Persistence\\ServerSalt' => $baseDir . '/lib/Persistence/ServerSalt.php',
|
'PrivateBin\\Persistence\\ServerSalt' => $baseDir . '/lib/Persistence/ServerSalt.php',
|
||||||
'PrivateBin\\Persistence\\TrafficLimiter' => $baseDir . '/lib/Persistence/TrafficLimiter.php',
|
'PrivateBin\\Persistence\\TrafficLimiter' => $baseDir . '/lib/Persistence/TrafficLimiter.php',
|
||||||
|
1
vendor/composer/autoload_static.php
vendored
1
vendor/composer/autoload_static.php
vendored
@ -52,6 +52,7 @@ class ComposerStaticInitDontChange
|
|||||||
'PrivateBin\\Model\\Comment' => __DIR__ . '/../..' . '/lib/Model/Comment.php',
|
'PrivateBin\\Model\\Comment' => __DIR__ . '/../..' . '/lib/Model/Comment.php',
|
||||||
'PrivateBin\\Model\\Paste' => __DIR__ . '/../..' . '/lib/Model/Paste.php',
|
'PrivateBin\\Model\\Paste' => __DIR__ . '/../..' . '/lib/Model/Paste.php',
|
||||||
'PrivateBin\\Persistence\\AbstractPersistence' => __DIR__ . '/../..' . '/lib/Persistence/AbstractPersistence.php',
|
'PrivateBin\\Persistence\\AbstractPersistence' => __DIR__ . '/../..' . '/lib/Persistence/AbstractPersistence.php',
|
||||||
|
'PrivateBin\\Persistence\\DataStore' => __DIR__ . '/../..' . '/lib/Persistence/DataStore.php',
|
||||||
'PrivateBin\\Persistence\\PurgeLimiter' => __DIR__ . '/../..' . '/lib/Persistence/PurgeLimiter.php',
|
'PrivateBin\\Persistence\\PurgeLimiter' => __DIR__ . '/../..' . '/lib/Persistence/PurgeLimiter.php',
|
||||||
'PrivateBin\\Persistence\\ServerSalt' => __DIR__ . '/../..' . '/lib/Persistence/ServerSalt.php',
|
'PrivateBin\\Persistence\\ServerSalt' => __DIR__ . '/../..' . '/lib/Persistence/ServerSalt.php',
|
||||||
'PrivateBin\\Persistence\\TrafficLimiter' => __DIR__ . '/../..' . '/lib/Persistence/TrafficLimiter.php',
|
'PrivateBin\\Persistence\\TrafficLimiter' => __DIR__ . '/../..' . '/lib/Persistence/TrafficLimiter.php',
|
||||||
|
Loading…
Reference in New Issue
Block a user