aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAbijeet <abijeetpatro@gmail.com>2017-12-28 01:41:16 +0530
committerAbijeet <abijeetpatro@gmail.com>2018-01-08 23:47:52 +0530
commitde5467811a52abcc16d0b536136e09f1b614d79c (patch)
treeba32f0db3b4ae44bd4c122d175f91fd6d4e0d208
parentf25e51c3691e8dce3c0f6c8ed56f4effa9ebb0dc (diff)
downloadnextcloud-server-de5467811a52abcc16d0b536136e09f1b614d79c.tar.gz
nextcloud-server-de5467811a52abcc16d0b536136e09f1b614d79c.zip
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>
-rw-r--r--core/js/js.js7
-rw-r--r--lib/private/Template/JSConfigHelper.php1
2 files changed, 6 insertions, 2 deletions
diff --git a/core/js/js.js b/core/js/js.js
index f9a5f2b3381..872761c02bb 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -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);
},
diff --git a/lib/private/Template/JSConfigHelper.php b/lib/private/Template/JSConfigHelper.php
index bdb747e1c9f..9f93ef784bc 100644
--- a/lib/private/Template/JSConfigHelper.php
+++ b/lib/private/Template/JSConfigHelper.php
@@ -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'),