- numerous bug fixes - wtv-mail system - user account updates - viewergen alpha (experimental webtv viewer patcher on pc_service) - implement wtv-favorites with huge help from @JarHead4 - add wtv-ticket store api - Bump vm2 from 3.9.5 to 3.9.7 in /zefie_wtvp_minisrv - fix bf0app default rom - Add wtv-1800 service to wtv-1800:/noflash - handle webtvism: - allow get/post variables to be the same name multiple times - rather than overwrite, the server will now change the variable from a string to an array. - Rewrite script processing a bit - Instead of using eval() we now use a proper VM Context - As a result, any scripting errors will now give a more useful filename and line number. - However, some things may break, if they are dependant on variables we are not allowing in the context. - BREAKING CHANGES: - `ssid_sessions[socket.ssid]` is now `session_data` - `require` is no longer allowed in user scripts - add star service - change how we handle modules for services in the VM - fixed wtv-disk:/sync always failed the first time - implement production-like wtv-star handling (when a service port becomes unavailable, it requests the url over the wtv-star port to show an error page) - renamed WTVDownloadList.js to WTVDisk.js - a bit more work on WTVNews (created class) - probably more stuff I can't remember
97 lines
3.5 KiB
JavaScript
97 lines
3.5 KiB
JavaScript
var minisrv_service_file = true;
|
|
|
|
var challenge_response, challenge_header = '';
|
|
var gourl;
|
|
var wtvsec_login = null;
|
|
|
|
if (request_headers.query.hangup) {
|
|
headers = `300 OK
|
|
Location: client:gototvhome
|
|
wtv-visit: client:hangupphone`
|
|
} else {
|
|
|
|
var user_id = (request_headers.query.user_id) ? request_headers.query.user_id : session_data.user_id;
|
|
|
|
if (socket.ssid !== null && user_id !== null) session_data.switchUserID(user_id);
|
|
|
|
if (socket.ssid !== null && !session_data.get("wtvsec_login")) {
|
|
wtvsec_login = new WTVSec(minisrv_config);
|
|
wtvsec_login.IssueChallenge();
|
|
wtvsec_login.set_incarnation(request_headers["wtv-incarnation"]);
|
|
session_data.set("wtvsec_login", wtvsec_login);
|
|
} else {
|
|
wtvsec_login = session_data.get("wtvsec_login");
|
|
}
|
|
|
|
if (socket.ssid !== null) {
|
|
if (wtvsec_login.ticket_b64 == null) {
|
|
challenge_response = wtvsec_login.challenge_response;
|
|
var client_challenge_response = request_headers["wtv-challenge-response"] || null;
|
|
if (challenge_response && client_challenge_response) {
|
|
if (challenge_response.toString(CryptoJS.enc.Base64) == client_challenge_response) {
|
|
console.log(" * wtv-challenge-response success for " + wtvshared.filterSSID(socket.ssid));
|
|
wtvsec_login.PrepareTicket();
|
|
gourl = "wtv-head-waiter:/login-stage-two?";
|
|
} else {
|
|
console.log(" * wtv-challenge-response FAILED for " + wtvshared.filterSSID(socket.ssid));
|
|
if (minisrv_config.config.debug_flags.debug) console.log("Response Expected:", challenge_response.toString(CryptoJS.enc.Base64));
|
|
if (minisrv_config.config.debug_flags.debug) console.log("Response Received:", client_challenge_response)
|
|
gourl = "wtv-head-waiter:/login?reissue_challenge=true";
|
|
}
|
|
} else {
|
|
gourl = "wtv-head-waiter:/login?no_response=true";
|
|
}
|
|
} else {
|
|
gourl = "wtv-head-waiter:/login-stage-two?";
|
|
}
|
|
}
|
|
|
|
if (request_headers.query.guest_login) {
|
|
if (request_headers.query.relogin || request_headers.query.reconnect) gourl += "&";
|
|
gourl += "guest_login=true";
|
|
if (request_headers.query.skip_splash) gourl += "&skip_splash=true";
|
|
}
|
|
|
|
if (user_id != null && !request_headers.query.initial_login && !request_headers.query.user_login) {
|
|
if (request_headers.query.password == "") {
|
|
headers = `403 Please enter your password and try again
|
|
minisrv-no-mail-count: true
|
|
`;
|
|
} else if (session_data.validateUserPassword(request_headers.query.password)) {
|
|
session_data.setUserLoggedIn(true);
|
|
headers = `200 OK
|
|
minisrv-no-mail-count: true
|
|
Content-Type: text/html
|
|
wtv-visit: ${gourl}
|
|
`;
|
|
} else {
|
|
headers = `403 The password you entered was incorrect. Please retype it and try again.
|
|
minisrv-no-mail-count: true
|
|
`;
|
|
}
|
|
} else {
|
|
if (session_data.baddisk === true) {
|
|
gourl = "wtv-head-waiter:/bad-disk?"
|
|
}
|
|
else if (session_data.getNumberOfUserAccounts() > 1 && user_id === 0 && request_headers.query.initial_login) {
|
|
gourl = "wtv-head-waiter:/choose-user?"
|
|
} else {
|
|
var limitedLogin = (!session_data.lockdown && (!session_data.get('password_valid') && session_data.getUserPasswordEnabled()));
|
|
var limitedLoginRegistered = (limitedLogin && session_data.isRegistered());
|
|
}
|
|
headers = `200 OK
|
|
wtv-connection-close: true
|
|
Connection: close
|
|
minisrv-no-mail-count: true
|
|
Content-Type: text/html`;
|
|
if (client_challenge_response) {
|
|
headers += `
|
|
wtv-encrypted: true`;
|
|
if (wtvsec_login) session_data.data_store.wtvsec_login.update_ticket = true;
|
|
}
|
|
if (limitedLoginRegistered) gourl = "wtv-head-waiter:/password?";
|
|
headers += `
|
|
wtv-visit: ${gourl}`;
|
|
|
|
}
|
|
} |