guest mode session store update
- allow calls to saveSessionData() but do not actually write if user is guest - saveSessionData() returns true even if guest, because false is meant to define an error - You can also use SaveIfRegistered(), this will return false on both saveSessionData() errors AND guest mode; - if you want to block guests, check for isRegistered() and block the request if it is false - otherwise this update will allow all tools (including any logins) to work with guest mode, but the stored SessionData will not be persistently saved, and lost when the cleanup timeout hits (default 3 min), or the server is restarted.
This commit is contained in:
@@ -94,9 +94,6 @@ class WTVClientSessionData {
|
||||
|
||||
this.session_store.cookies[cookie_index] = Object.assign({}, cookie_data);
|
||||
|
||||
// do not write file if user is not registered
|
||||
if (this.getSessionData('registered')) this.storeSessionData();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -193,11 +190,16 @@ class WTVClientSessionData {
|
||||
}
|
||||
|
||||
saveSessionData() {
|
||||
if (this.isRegistered()) {
|
||||
// load data from disk and merge new data
|
||||
var temp_store = this.session_store;
|
||||
if (this.loadSessionData()) this.session_store = Object.assign(this.session_store, temp_store);
|
||||
else this.session_store = temp_store;
|
||||
temp_store = null;
|
||||
} else {
|
||||
// do not write file if user is not registered, return true because this is not an error
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
// only save if file has changed
|
||||
@@ -213,7 +215,7 @@ class WTVClientSessionData {
|
||||
|
||||
retrieveSessionData() {
|
||||
// alias
|
||||
this.loadSessionData();
|
||||
return this.loadSessionData();
|
||||
}
|
||||
|
||||
storeSessionData() {
|
||||
@@ -222,7 +224,8 @@ class WTVClientSessionData {
|
||||
}
|
||||
|
||||
SaveIfRegistered() {
|
||||
if (this.isRegistered()) this.saveSessionData();
|
||||
if (this.isRegistered()) return this.saveSessionData();
|
||||
return false;
|
||||
}
|
||||
|
||||
isRegistered() {
|
||||
|
||||
Reference in New Issue
Block a user