Fixes password input being prompted every time.
Fixes #7106 - Echoing the current server time via a JS variable and storing the current time on page load in JS. - Calculating the diff and taking it into account when deciding whether to show the password confirmation. Signed-off-by: Abijeet <abijeetpatro@gmail.com>
This commit is contained in:
parent
f25e51c369
commit
de5467811a
|
@ -1675,13 +1675,16 @@ function initCore() {
|
|||
|
||||
OC.PasswordConfirmation = {
|
||||
callback: null,
|
||||
|
||||
pageLoadTime: null,
|
||||
init: function() {
|
||||
$('.password-confirm-required').on('click', _.bind(this.requirePasswordConfirmation, this));
|
||||
this.pageLoadTime = moment.now();
|
||||
},
|
||||
|
||||
requiresPasswordConfirmation: function() {
|
||||
var timeSinceLogin = moment.now() - (nc_lastLogin * 1000);
|
||||
var serverTimeDiff = this.pageLoadTime - (nc_pageLoad * 1000);
|
||||
var timeSinceLogin = moment.now() - (serverTimeDiff + (nc_lastLogin * 1000));
|
||||
|
||||
// if timeSinceLogin > 30 minutes and user backend allows password confirmation
|
||||
return (backendAllowsPasswordConfirmation && timeSinceLogin > 30 * 60 * 1000);
|
||||
},
|
||||
|
|
|
@ -155,6 +155,7 @@ class JSConfigHelper {
|
|||
"oc_appswebroots" => str_replace('\\/', '/', json_encode($apps_paths)), // Ugly unescape slashes waiting for better solution
|
||||
"datepickerFormatDate" => json_encode($this->l->l('jsdate', null)),
|
||||
'nc_lastLogin' => $lastConfirmTimestamp,
|
||||
'nc_pageLoad' => time(),
|
||||
"dayNames" => json_encode([
|
||||
(string)$this->l->t('Sunday'),
|
||||
(string)$this->l->t('Monday'),
|
||||
|
|
Loading…
Reference in New Issue