diff --git a/dev/Storage/RainLoop.jsx b/dev/Storage/RainLoop.jsx
index b404f6372..0c01d7904 100644
--- a/dev/Storage/RainLoop.jsx
+++ b/dev/Storage/RainLoop.jsx
@@ -1,7 +1,10 @@
import window from 'window';
-const STORAGE_KEY = '__rlA';
+const
+ STORAGE_KEY = '__rlA',
+ TIME_KEY = '__rlT'
+;
class RainLoopStorage
{
@@ -12,50 +15,90 @@ class RainLoopStorage
{
this.s = window.sessionStorage || null;
this.t = window.top || window;
+
+ this.init();
}
- getHash() {
+ __get(key) {
+
let result = null;
if (this.s)
{
- result = this.s.getItem(STORAGE_KEY) || null;
+ result = this.s.getItem(key) || null;
}
else if (this.t && JSON)
{
const data = this.t.name && '{' === this.t.name.toString().substr(0, 1) ? JSON.parse(this.t.name.toString()) : null;
- result = data ? (data[STORAGE_KEY] || null) : null;
+ result = data ? (data[key] || null) : null;
}
return result;
}
- setHash() {
- const
- key = 'AuthAccountHash',
- appData = window.__rlah_data()
- ;
+ __set(key, value) {
if (this.s)
{
- this.s.setItem(STORAGE_KEY, appData && appData[key] ? appData[key] : '');
+ this.s.setItem(key, value);
}
else if (this.t && JSON)
{
- let data = {};
- data[STORAGE_KEY] = appData && appData[key] ? appData[key] : '';
+ let data = this.t.name && '{' === this.t.name.toString().substr(0, 1) ? JSON.parse(this.t.name.toString()) : null;
+ data = data || {};
+ data[key] = value;
this.t.name = JSON.stringify(data);
}
}
+ timestamp() {
+ return window.Math.round((new Date()).getTime() / 1000);
+ }
+
+ init() {
+
+ const
+ six = 1000 * 60 * 6, // 6m
+ now = this.timestamp()
+ ;
+
+ if (now > this.getTimestamp() + six * 10)
+ {
+ this.clearHash();
+ }
+
+ window.setInterval(() => {
+ this.setTimestamp();
+ }, six);
+ }
+
+ getHash() {
+ return this.__get(STORAGE_KEY);
+ }
+
+ setHash() {
+
+ const
+ key = 'AuthAccountHash',
+ appData = window.__rlah_data()
+ ;
+
+ this.__set(STORAGE_KEY, appData && appData[key] ? appData[key] : '');
+ this.setTimestamp();
+ }
+
+
+ setTimestamp() {
+ this.__set(TIME_KEY, this.timestamp());
+ }
+
+ getTimestamp() {
+ let time = this.__get(TIME_KEY, 0);
+ return time ? (window.parseInt(time, 10) | 0) : 0;
+ }
+
clearHash() {
- if (this.s)
- {
- this.s.setItem(STORAGE_KEY, '');
- }
- else if (this.t)
- {
- this.t.name = '';
- }
+ this.__set(STORAGE_KEY, '');
+ this.setTimestamp();
}
}
diff --git a/rainloop/v/0.0.0/app/templates/Views/User/PopupsTwoFactorConfiguration.html b/rainloop/v/0.0.0/app/templates/Views/User/PopupsTwoFactorConfiguration.html
index b3cbb6c2e..2d38d6bce 100644
--- a/rainloop/v/0.0.0/app/templates/Views/User/PopupsTwoFactorConfiguration.html
+++ b/rainloop/v/0.0.0/app/templates/Views/User/PopupsTwoFactorConfiguration.html
@@ -91,7 +91,7 @@
-
+