Bug fixes

- wtv-tricks:/unregister properly deletes SSID folder
- Registration properly saves account data if SSID folder doesn't exist
- do not send wtv-mail-count if SSID is not yet registered
- Registration now correctly creates the welcome message for user0
- update wtv-tricks:/unregister to only allow the primary user to unregister the account
This commit is contained in:
zefie
2022-03-12 15:14:32 -05:00
parent 8acb801ef0
commit 2be8c66b01
4 changed files with 24 additions and 3 deletions

View File

@@ -19,7 +19,20 @@ if (!request_headers.query.registering ||
ssid_sessions[socket.ssid].setSessionData("subscriber_contact_method", request_headers.query.subscriber_contact_method);
ssid_sessions[socket.ssid].setSessionData("subscriber_userid", 0);
ssid_sessions[socket.ssid].setSessionData("registered", true);
if (!ssid_sessions[socket.ssid].storeSessionData(true, true)) {
var mailstore_exists = ssid_sessions[socket.ssid].mailstore.mailstoreExists();
var mailbox_exists = false;
if (!mailstore_exists) mailstore_exists = ssid_sessions[socket.ssid].mailstore.createMailstore();
if (mailstore_exists) {
if (!ssid_sessions[socket.ssid].mailstore.mailboxExists(0)) {
// mailbox does not yet exist, create it
mailbox_exists = ssid_sessions[socket.ssid].mailstore.createMailbox(0);
}
if (mailbox_exists) {
// Just created Inbox for the first time, so create the welcome message
ssid_sessions[socket.ssid].mailstore.createWelcomeMessage();
}
}
if (!ssid_sessions[socket.ssid].saveSessionData(true, true)) {
var errpage = wtvshared.doErrorPage(400);
headers = errpage[0];
data = errpage[1];

View File

@@ -8,6 +8,11 @@ if (!ssid_sessions[socket.ssid].getSessionData("registered")) {
headers += "\nwtv-expire-all: wtv-";
var redirect = [5, "client:relogin?"];
var message = "Error: Your box is not registered. You are accessing " + minisrv_config.config.service_name + " in Guest Mode. There is nothing to delete!";
} else if (ssid_sessions[socket.ssid].user_id !== 0) {
headers += "\nwtv-noback-all: wtv-";
headers += "\nwtv-expire-all: wtv-";
var redirect = [5, "wtv-tricks:/tricks"];
var message = "Error: You must be the primary user to unregister this box.";
} else if (request_headers.query.confirm_unregister) {
if (ssid_sessions[socket.ssid].unregisterBox()) {
headers += "\nwtv-noback-all: wtv-";

View File

@@ -127,6 +127,7 @@ class WTVClientSessionData {
}
getNumberOfUserAccounts() {
if (!this.isRegistered()) return false;
if (this.user_id != 0) return false; // subscriber only command
return Object.keys(this.listPrimaryAccountUsers()).length;
}

View File

@@ -747,10 +747,12 @@ async function sendToClient(socket, headers_obj, data) {
if (!headers_obj['minisrv-no-mail-count']) {
if (ssid_sessions[socket.ssid]) {
if (ssid_sessions[socket.ssid].isRegistered()) {
if (ssid_sessions[socket.ssid].mailstore) {
headers_obj['wtv-mail-count'] = ssid_sessions[socket.ssid].mailstore.countUnreadMessages(0);
}
}
}
} else {
if (headers_obj['wtv-mail-count']) delete headers_obj['wtv-mail-count'];
delete headers_obj['minisrv-no-mail-count'];