more patches to previous updates

- fixed getUnreadMailCount
- added unread mail count to login screen
- added session busted detection (new bug that when you restart minisrv it loses the user_id, so we send the client to relog) (todo: maybe add api to add key/value to ticket so we can retain data over server restarts)
This commit is contained in:
zefie
2022-02-08 04:58:16 -05:00
parent 07b5145dec
commit 433fc3db19
5 changed files with 45 additions and 24 deletions

View File

@@ -397,14 +397,25 @@ async function processURL(socket, request_headers) {
if (!ssid_sessions[socket.ssid].isUserLoggedIn() && !ssid_sessions[socket.ssid].isAuthorized(shortURL, 'login')) {
// lockdown mode and URL not authorized
headers = "300 Unauthorized\n";
headers += "Location: " + minisrv_config.config.unauthorized_url + "\n";
headers = `300 Unauthorized
Location: " + minisrv_config.config.unauthorized_url`;
data = "";
sendToClient(socket, headers, data);
console.log(" * Rejected login bypass request for " + shortURL + " on socket ID", socket.id);
return;
}
if (ssid_sessions[socket.ssid].isRegistered(false) && !ssid_sessions[socket.ssid].isAuthorized(shortURL, 'login', true)) {
if (!ssid_sessions[socket.ssid].getSessionData("subscriber_username")) {
headers = `300 Session Error
Location: client:relogin`;
data = "";
sendToClient(socket, headers, data);
console.log(" * Session error: Asking client to relogin via socket ID", socket.id);
return;
}
}
// Check URL for :/, but not :// (to differentiate wtv urls)
if (shortURL.indexOf(':/') >= 0 && shortURL.indexOf('://') == -1) {