user account updates

- move user accounts to subdir
- add password support
- implemented basics of multi-user support
- Can add users, edit them, and log in with them (password or not)
- Cannot delete users (with service) yet
This commit is contained in:
zefie
2022-02-07 20:24:16 -05:00
parent 622698ee66
commit 0d991d5eac
35 changed files with 2228 additions and 154 deletions

View File

@@ -0,0 +1,133 @@
var minisrv_service_file = true;
ssid_sessions[socket.ssid].loadSessionData();
if (ssid_sessions[socket.ssid].user_id != 0) {
var errpage = doErrorPage(400, "You are not authorized to edit the primary account.");
headers = errpage[0];
data = errpage[1];
} else {
headers = `200 OK
Connection: Keep-Alive
Content-Type: text/html`
data = `<HTML>
<HTML>
<HEAD>
<TITLE>
Users setup
</TITLE>
<DISPLAY >
</HEAD>
<sidebar width=110> <table cellspacing=0 cellpadding=0 BGCOLOR="30364D">
<tr>
<td colspan=3 abswidth=104 absheight=4>
<td rowspan=99 width=6 absheight=420 valign=top align=left>
<img src="wtv-home:/ROMCache/Shadow.gif" width=6 height=420>
<tr>
<td abswidth=6>
<td abswidth=92 absheight=76>
<table href="wtv-home:/home" absheight=76 cellspacing=0 cellpadding=0>
<tr>
<td align=right>
<img src="${minisrv_config.config.service_logo}" width=87 height=67>
</table>
<td abswidth=6>
<tr><td absheight=5 colspan=3>
<table cellspacing=0 cellpadding=0>
<tr><td abswidth=104 absheight=2 valign=middle align=center bgcolor="1C1E28">
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
<tr><td abswidth=104 absheight=1 valign=top align=left>
<tr><td abswidth=104 absheight=2 valign=top align=left bgcolor="4D5573">
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
</table>
<tr><td absheight=37>
<tr><td absheight=263 align=right colspan=3>
<img src="ROMCache/AccountBanner.gif" width=53 height=263>
<tr><td absheight=41>
</table>
</sidebar>
<BODY NOHTILEBG BGCOLOR="#191919" TEXT="#42CC55" LINK="36d5ff" VLINK="36d5ff" HSPACE=0 VSPACE=0 FONTSIZE="large"
>
<table cellspacing=0 cellpadding=0>
<tr>
<td abswidth=14>
<td colspan=3>
<table cellspacing=0 cellpadding=0>
<tr>
<td valign=center absheight=80>
<font size="+2" color="E7CE4A"><blackface><shadow>
WebTV users
</table>
<td abswidth=20>
<TR>
<td>
<td WIDTH=198 HEIGHT=244 VALIGN=top ALIGN=left>
<FONT COLOR="44cc55"><B>
Subscriber:
<P>`;
var accounts = ssid_sessions[socket.ssid].listPrimaryAccountUsers();
if (Object.keys(accounts).length > 1) data += "Additional users:</B></FONT>";
data += "<TD WIDTH=20><TD WIDTH=198 VALIGN=top ALIGN=left>";
data += `<FORM>
<FONT COLOR="189CD6"><B>
<A HREF="wtv-setup:/edit-user-begin?user_id=0">${accounts.subscriber.subscriber_username}</A>
</B></FONT>
<P>`;
if (Object.keys(accounts).length > 1) {
delete accounts.subscriber;
for (const [key, value] of Object.entries(accounts)) {
data += `<FONT COLOR="189CD6"><B>
<A HREF="wtv-setup:/edit-user-begin?user_id=${key.replace("user", '')}">${value.subscriber_username}</A>
`;
};
}
data += `
</B></FONT>
<BR>
<TR>
<TD>
<TD COLSPAN=4 HEIGHT=4 VALIGN=top ALIGN=left>
<tr>
<TD>
<td colspan=4 height=2 valign=middle align=center bgcolor="2B2B2B">
<img src="wtv-home:/ROMCache/Spacer.gif" width=436 height=1>
<tr>
<TD>
<td colspan=4 height=1 valign=top align=left>
<tr>
<TD>
<td colspan=4 height=2 valign=top align=left bgcolor="0D0D0D">
<img src="wtv-home:/ROMCache/Spacer.gif" width=436 height=1>
<TR>
<TD>
<TD COLSPAN=4 HEIGHT=4 VALIGN=top ALIGN=left>
<TR>
<TD>
<TD COLSPAN=3 VALIGN=top ALIGN=right>
<FONT COLOR="#E7CE4A" SIZE=-1><SHADOW>
<INPUT action="/remove-users?user-count=x"
name="RemoveUser" value="Remove User" WIDTH=140 ${(Object.keys(accounts).length <= 1) ? 'USESTYLE' : 'disabled="disabled" text=gray' }
TYPE=SUBMIT BORDERIMAGE="file://ROM/Borders/ButtonBorder2.bif" NAME="Button1" WIDTH=103>
<IMG SRC="wtv-home:/ROMCache/Spacer.gif" WIDTH=4 HEIGHT=1>
<INPUT action="/add-user?user_count=${Object.keys(accounts).length}"
name="AddUser" value="Add User" WIDTH=120 ${(Object.keys(accounts).length >= minisrv_config.config.user_accounts.max_users_per_account) ? 'disabled="disabled" text=gray' : 'USESTYLE'}
TYPE=SUBMIT BORDERIMAGE="file://ROM/Borders/ButtonBorder2.bif" NAME="Button2" WIDTH=103>
<IMG SRC="wtv-home:/ROMCache/Spacer.gif" WIDTH=4 HEIGHT=1>
<INPUT action="client:goback"
name="Done"
value="Done"
WIDTH=120
selected
TYPE=SUBMIT BORDERIMAGE="file://ROM/Borders/ButtonBorder2.bif" NAME="Button3" USESTYLE WIDTH=103>
</SHADOW></FONT></FORM>
<TD>
</TABLE>
</BODY>
</HTML>
`;
}

View File

@@ -0,0 +1,136 @@
var minisrv_service_file = true;
if (ssid_sessions[socket.ssid].user_id != 0) errpage = wtvshared.doErrorPage(400, "You are not authorized to add users to this account.");
else if (ssid_sessions[socket.ssid].getNumberOfUserAccounts() > minisrv_config.config.user_accounts.max_users_per_account) errpage = wtvshared.doErrorPage(400, "You are not authorized to add more than " + minisrv_config.config.user_accounts.max_users_per_account + " account${minisrv_config.config.user_accounts.max_users_per_account > 1 ? 's' : ''}.");
else if (!request_headers.query.user_name) errpage = wtvshared.doErrorPage(400, "Please enter a username.");
if (errpage) {
headers = errpage[0];
data = errpage[1];
} else {
headers = `200 OK
Connection: Keep-Alive
Content-Type: text/html`
data = `<HTML>
<HTML>
<HEAD>
<TITLE>
Adding a User
</TITLE>
<DISPLAY nosave
noscroll>
</HEAD>
<sidebar width=110> <table cellspacing=0 cellpadding=0 BGCOLOR="30364D">
<tr>
<td colspan=3 abswidth=104 absheight=4>
<td rowspan=99 width=6 absheight=420 valign=top align=left>
<img src="wtv-home:/ROMCache/Shadow.gif" width=6 height=420>
<tr>
<td abswidth=6>
<td abswidth=92 absheight=76>
<table href="wtv-home:/home" absheight=76 cellspacing=0 cellpadding=0>
<tr>
<td align=right>
<img src="${minisrv_config.config.service_logo}" width=87 height=67>
</table>
<td abswidth=6>
<tr><td absheight=5 colspan=3>
<table cellspacing=0 cellpadding=0>
<tr><td abswidth=104 absheight=2 valign=middle align=center bgcolor="1C1E28">
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
<tr><td abswidth=104 absheight=1 valign=top align=left>
<tr><td abswidth=104 absheight=2 valign=top align=left bgcolor="4D5573">
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
</table>
<tr><td absheight=37>
<tr><td absheight=263 align=right colspan=3>
<img src="ROMCache/AccountBanner.gif" width=53 height=263>
<tr><td absheight=41>
</table>
</sidebar>
<BODY BGCOLOR="#191919" TEXT="#44cc55" LINK="189CD6" VLINK="189CD6" HSPACE=0 VSPACE=0 FONTSIZE="large"
>
<table cellspacing=0 cellpadding=0>
<tr>
<td abswidth=14>
<td abswidth=416 absheight=80 valign=center>
<font size="+2" color="E7CE4A"><blackface><shadow>
User's Internet name
<td abswidth=20>
<tr>
<td>
<td absheight=244 valign=top align=left>
<form action="wtv-setup:/add-user-password">
<INPUT TYPE="hidden" NAME="display_name" VALUE="${request_headers.query.display_name || ''}">
<table cellspacing=0 cellpadding=0 border=0>
<tr>
<td align=left valign=top abswidth=198>
<table cellspacing=0 cellpadding=0>
<tr>
<td align=left>
Type an Internet<br>
name`;
if (request_headers.query.display_name) {
data += ` for <b>${request_headers.query.display_name}</b>.`
} else {
data += "."
} data += `
<p>Internet names can<br>
contain letters and<br>
numbers, but no<br>
spaces.
</a>
</table>
</td>
<td align=left valign=top width=6>
</td>
<td align=left valign=top abswidth=210>
<table cellspacing=0 cellpadding=0>
<tr>
<td colspan=3 align=left>
Internet name<br>
<INPUT noSubmit name="user_name" id="user_name" Value="${request_headers.query.display_name || ''}"
bgcolor=#444444 text=#ffdd33 cursor=#cc9933
TYPE="text" ASCIIONLY
SIZE="18"
MAXLENGTH="18">
<tr>
<td height=6>
<tr>
<td colspan=3 align=left>
</a>
</table>
</table>
<td>
<tr>
<td absheight=7>
<tr>
<td>
<td colspan=2 absheight=2 bgcolor="2B2B2B">
<img src="wtv-home:/ROMCache/Spacer.gif" width=426 height=1>
<tr>
<td absheight=1>
<tr>
<td>
<td colspan=2 absheight=2 bgcolor="0D0D0D">
<img src="wtv-home:/ROMCache/Spacer.gif" width=426 height=1>
<tr>
<td absheight=4>
</table>
<table cellspacing=0 cellpadding=0>
<tr>
<td abswidth=430 valign=top align=right>
<font color="#E7CE4A" size=-1><shadow>
<input
selected
type=submit borderimage="file://ROM/Borders/ButtonBorder2.bif"
value=Continue name="Continue" usestyle width=103>
</shadow></font></form>
<td abswidth=20>
</table>
</body>
</html>
`;
}

View File

@@ -0,0 +1,150 @@
var minisrv_service_file = true;
var errpage = null;
const WTVRegister = require("./WTVRegister.js")
const wtvr = new WTVRegister(minisrv_config, SessionStore);
if (ssid_sessions[socket.ssid].user_id != 0) errpage = wtvshared.doErrorPage(400, "You are not authorized to add users to this account.");
else if (!request_headers.query.user_name) errpage = doErrorPage(400, "Please enter a username.");
else if (request_headers.query.user_name.length < minisrv_config.config.user_accounts.min_length) errpage = wtvshared.doErrorPage(400, "Please choose a username with " + minisrv_config.config.user_accounts.min_length + " or more characters.");
else if (request_headers.query.user_name.length > minisrv_config.config.user_accounts.max_length) errpage = wtvshared.doErrorPage(400, "Please choose a username with " + minisrv_config.config.user_accounts.max_length + " or less characters.");
else if (!wtvr.checkUsernameSanity(request_headers.query.user_name)) errpage = wtvshared.doErrorPage(400, "The username you have chosen contains invalid characters. Please choose a username with only <b>letters</b>, <b>numbers</b>, <b>_</b> or <b>-</b>. Also, please be sure your username begins with a letter.");
else if (!wtvr.checkUsernameAvailable(request_headers.query.user_name, ssid_sessions)) errpage = wtvshared.doErrorPage(400, "The username you have selected is already in use. Please select another username.");
else if (ssid_sessions[socket.ssid].getNumberOfUserAccounts() > minisrv_config.config.user_accounts.max_users_per_account) errpage = wtvshared.doErrorPage(400, "You are not authorized to add more than " + minisrv_config.config.user_accounts.max_users_per_account + " account${minisrv_config.config.user_accounts.max_users_per_account > 1 ? 's' : ''}.");
if (errpage) {
headers = errpage[0];
data = errpage[1];
} else {
headers = `200 OK
Connection: Keep-Alive
Content-Type: text/html`
data = `<HTML>
<HTML>
<HEAD>
<TITLE>
Adding a User
</TITLE>
<DISPLAY nosave
noscroll>
</HEAD>
<sidebar width=110> <table cellspacing=0 cellpadding=0 BGCOLOR="30364D">
<tr>
<td colspan=3 abswidth=104 absheight=4>
<td rowspan=99 width=6 absheight=420 valign=top align=left>
<img src="wtv-home:/ROMCache/Shadow.gif" width=6 height=420>
<tr>
<td abswidth=6>
<td abswidth=92 absheight=76>
<table href="wtv-home:/home" absheight=76 cellspacing=0 cellpadding=0>
<tr>
<td align=right>
<img src="${minisrv_config.config.service_logo}" width=87 height=67>
</table>
<td abswidth=6>
<tr><td absheight=5 colspan=3>
<table cellspacing=0 cellpadding=0>
<tr><td abswidth=104 absheight=2 valign=middle align=center bgcolor="1C1E28">
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
<tr><td abswidth=104 absheight=1 valign=top align=left>
<tr><td abswidth=104 absheight=2 valign=top align=left bgcolor="4D5573">
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
</table>
<tr><td absheight=37>
<tr><td absheight=263 align=right colspan=3>
<img src="ROMCache/AccountBanner.gif" width=53 height=263>
<tr><td absheight=41>
</table>
</sidebar>
<BODY BGCOLOR="#191919" TEXT="#44cc55" LINK="189CD6" VLINK="189CD6" HSPACE=0 VSPACE=0 FONTSIZE="large"
>
<table cellspacing=0 cellpadding=0>
<tr>
<td abswidth=14>
<td abswidth=416 absheight=80 valign=center>
<font size="+2" color="E7CE4A"><blackface><shadow>
Optional password
<td abswidth=20>
<tr>
<td>
<td absheight=244 valign=top align=left>
<form action="wtv-setup:/validate-add-user">
<INPUT TYPE="hidden" NAME="display_name" VALUE="${request_headers.query.display_name}">
<INPUT TYPE="hidden" NAME="user_name" VALUE="${request_headers.query.user_name}">
<table cellspacing=0 cellpadding=0 border=0>
<tr>
<td align=left valign=top abswidth=198>
<table cellspacing=0 cellpadding=0>
<tr>
<td align=left>
Type an optional<br>
password from ${minisrv_config.config.passwords.min_length} to
<br>${minisrv_config.config.passwords.max_length} characters long.
<p>You'll need to type<br>
the password<br>
Whenever you switch to <b>${request_headers.query.user_name}</b>.<br>
<p>Leave the spaces<br>
blank if you don't<br>
want a password.
</a>
</table>
</td>
<td align=left valign=top width=6>
</td>
<td align=left valign=top abswidth=210>
<table cellspacing=0 cellpadding=0>
<tr>
<td colspan=3 align=left>
Password<br>
<INPUT noSubmit name="user_password" id="user_password" Value=""
bgcolor=#444444 text=#ffdd33 cursor=#cc9933
TYPE="password" ASCIIONLY
SIZE="${minisrv_config.config.passwords.form_size}"
MAXLENGTH="${minisrv_config.config.passwords.max_length}">
<tr>
<td height=6>
<tr>
<td colspan=3 align=left>
<br>Type again to confirm<br>
<INPUT noSubmit name="user_password2" id="user_password2" Value=""
bgcolor=#444444 text=#ffdd33 cursor=#cc9933
TYPE="password" ASCIIONLY
SIZE="${minisrv_config.config.passwords.form_size}"
MAXLENGTH="${minisrv_config.config.passwords.max_length}">
</table>
</table>
<td>
<tr>
<td absheight=7>
<tr>
<td>
<td colspan=2 absheight=2 bgcolor="2B2B2B">
<img src="wtv-home:/ROMCache/Spacer.gif" width=426 height=1>
<tr>
<td absheight=1>
<tr>
<td>
<td colspan=2 absheight=2 bgcolor="0D0D0D">
<img src="wtv-home:/ROMCache/Spacer.gif" width=426 height=1>
<tr>
<td absheight=4>
</table>
<table cellspacing=0 cellpadding=0>
<tr>
<td abswidth=430 valign=top align=right>
<font color="#E7CE4A" size=-1><shadow>
<input
selected
type=submit borderimage="file://ROM/Borders/ButtonBorder2.bif"
value=Continue name="Continue" usestyle width=103>
</shadow></font></form>
<td abswidth=20>
</table>
</body>
</html>
`;
}

View File

@@ -0,0 +1,134 @@
var minisrv_service_file = true;
if (Object.keys(ssid_sessions[socket.ssid].listPrimaryAccountUsers()).length >= minisrv_config.config.user_accounts.max_users_per_account) {
errpage = wtvshared.doErrorPage(400, "You are not authorized to add more than " + minisrv_config.config.user_accounts.max_users_per_account + " account${minisrv_config.config.user_accounts.max_users_per_account > 1 ? 's' : ''}.");
}
else if (ssid_sessions[socket.ssid].user_id != 0) errpage = wtvshared.doErrorPage(400, "You are not authorized to add users to this account.");
if (errpage) {
headers = errpage[0];
data = errpage[1];
} else {
headers = `200 OK
Connection: Keep-Alive
Content-Type: text/html`
data = `<HTML>
<HTML>
<HEAD>
<TITLE>
Adding person's name
</TITLE>
<DISPLAY nosave
noscroll>
</HEAD>
<sidebar width=110> <table cellspacing=0 cellpadding=0 BGCOLOR="30364D">
<tr>
<td colspan=3 abswidth=104 absheight=4>
<td rowspan=99 width=6 absheight=420 valign=top align=left>
<img src="wtv-home:/ROMCache/Shadow.gif" width=6 height=420>
<tr>
<td abswidth=6>
<td abswidth=92 absheight=76>
<table href="wtv-home:/home" absheight=76 cellspacing=0 cellpadding=0>
<tr>
<td align=right>
<img src="${minisrv_config.config.service_logo}" width=87 height=67>
</table>
<td abswidth=6>
<tr><td absheight=5 colspan=3>
<table cellspacing=0 cellpadding=0>
<tr><td abswidth=104 absheight=2 valign=middle align=center bgcolor="1C1E28">
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
<tr><td abswidth=104 absheight=1 valign=top align=left>
<tr><td abswidth=104 absheight=2 valign=top align=left bgcolor="4D5573">
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
</table>
<tr><td absheight=37>
<tr><td absheight=263 align=right colspan=3>
<img src="ROMCache/AccountBanner.gif" width=53 height=263>
<tr><td absheight=41>
</table>
</sidebar>
<BODY BGCOLOR="#191919" TEXT="#44cc55" LINK="189CD6" VLINK="189CD6" HSPACE=0 VSPACE=0 FONTSIZE="large"
>
<table cellspacing=0 cellpadding=0>
<tr>
<td abswidth=14>
<td abswidth=416 absheight=80 valign=center>
<font size="+2" color="E7CE4A"><blackface><shadow>
User's name
<td abswidth=20>
<tr>
<td>
<td absheight=244 valign=top align=left>
<form
action="wtv-setup:/add-user-name"
>
<P>
<table cellspacing=0 cellpadding=0 border=0>
<tr>
<td align=left valign=top abswidth=198>
<table cellspacing=0 cellpadding=0>
<tr>
<td align=left>
Type the person's<br>
display name<br>
here. They are<br>
included when the<br>
user sends mail.
<p>Leave the space<br>
blank if you don't<br>
want to type this<br>
person's name.
</a>
</table>
</td>
<td align=left valign=top width=6>
</td>
<td align=left valign=top abswidth=210>
<table cellspacing=0 cellpadding=0>
<tr>
<td colspan=3 align=left>
Display name<br>
<INPUT noSubmit name="display_name" id="display_name" Value=""
bgcolor=#444444 text=#ffdd33 cursor=#cc9933
TYPE="text" ASCIIONLY
SIZE="18"
MAXLENGTH="18">
</a>
</table>
</table>
<td>
<tr>
<td absheight=7>
<tr>
<td>
<td colspan=2 absheight=2 bgcolor="2B2B2B">
<img src="wtv-home:/ROMCache/Spacer.gif" width=426 height=1>
<tr>
<td absheight=1>
<tr>
<td>
<td colspan=2 absheight=2 bgcolor="0D0D0D">
<img src="wtv-home:/ROMCache/Spacer.gif" width=426 height=1>
<tr>
<td absheight=4>
</table>
<table cellspacing=0 cellpadding=0>
<tr>
<td abswidth=430 valign=top align=right>
<font color="#E7CE4A" size=-1><shadow>
<input
selected
type=submit borderimage="file://ROM/Borders/ButtonBorder2.bif"
value=Continue name="Continue" usestyle width=103>
</shadow></font></form>
<td abswidth=20>
</table>
</body>
</html>
`;
}

View File

@@ -0,0 +1,167 @@
var minisrv_service_file = true;
ssid_sessions[socket.ssid].loadSessionData();
var user_id = (request_headers.query.user_id) ? request_headers.query.user_id : ssid_sessions[socket.ssid].user_id;
// security
if (ssid_sessions[socket.ssid].user_id != 0 && ssid_sessions[socket.ssid].user_id != user_id) {
user_id = null; // force unset
var errpage = wtvshared.doErrorPage(400, "You are not authorized to change the selected user's password.");
headers = errpage[0];
data = errpage[1];
}
if (user_id != null) {
var userSession = null;
if (ssid_sessions[socket.ssid].user_id == request_headers.query.user_id) userSession = ssid_sessions[socket.ssid];
else {
userSession = new WTVClientSessionData(minisrv_config, socket.ssid);
userSession.user_id = user_id;
}
if (!userSession.loadSessionData()) {
var errpage = wtvshared.doErrorPage(400, "Invalid user ID.");
headers = errpage[0];
data = errpage[1];
}
else {
headers = `200 OK
Connection: Keep-Alive
Content-Type: text/html`;
data = `
<HTML>
<HEAD>
<TITLE>
Change ${(user_id == ssid_sessions[socket.ssid].user_id) ? 'your' : 'user'} password
</TITLE>
<DISPLAY nosave
noscroll>
</HEAD>
<sidebar width=110> <table cellspacing=0 cellpadding=0 BGCOLOR="30364D">
<tr>
<td colspan=3 abswidth=104 absheight=4>
<td rowspan=99 width=6 absheight=420 valign=top align=left>
<img src="wtv-home:/ROMCache/Shadow.gif" width=6 height=420>
<tr>
<td abswidth=6>
<td abswidth=92 absheight=76>
<table href="wtv-home:/home" absheight=76 cellspacing=0 cellpadding=0>
<tr>
<td align=right>
<img src="${minisrv_config.config.service_logo}" width=87 height=67>
</table>
<td abswidth=6>
<tr><td absheight=5 colspan=3>
<table cellspacing=0 cellpadding=0>
<tr><td abswidth=104 absheight=2 valign=middle align=center bgcolor="1C1E28">
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
<tr><td abswidth=104 absheight=1 valign=top align=left>
<tr><td abswidth=104 absheight=2 valign=top align=left bgcolor="4D5573">
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
</table>
<tr><td absheight=37>
<tr><td absheight=263 align=right colspan=3>
<img src="ROMCache/AccountBanner.gif" width=53 height=263>
<tr><td absheight=41>
</table>
</sidebar>
<BODY BGCOLOR="#191919" TEXT="#44cc55" LINK="189CD6" VLINK="189CD6" HSPACE=0 VSPACE=0 FONTSIZE="large"
>
<table cellspacing=0 cellpadding=0>
<tr>
<td abswidth=14>
<td abswidth=416 absheight=80 valign=center>
<font size="+2" color="E7CE4A"><blackface><shadow>
Change ${(user_id == ssid_sessions[socket.ssid].user_id) ? 'your' : 'user'} password
<td abswidth=20>
<tr>
<td>
<td absheight=244 valign=top align=left>
<form
action="wtv-setup:/validate-change-password"
>
<P>
<table cellspacing=0 cellpadding=0 border=0>
<tr>
<td align=left valign=top abswidth=198>
<table cellspacing=0 cellpadding=0>
<tr>
<td align=left>
Type a password<br>
from ${minisrv_config.config.passwords.min_length} to ${minisrv_config.config.passwords.max_length} <br>
characters long.
<p>This password will be<br>
required to access<br>
this account. If you<br>
don't want this<br>
account to have a<br>
password, leave<br>
these spaces blank.
</a>
</table>
</td>
<td align=left valign=top width=6>
</td>
<td align=left valign=top abswidth=210>
<table cellspacing=0 cellpadding=0>
<tr>
<td colspan=3 align=left>
Password<br>
<INPUT type="hidden" name="user_id" value="${user_id}">`;
if (request_headers.Referer) data += `
<INPUT type="hidden" name="return_to" value="${request_headers.Referer}">`;
data += `<INPUT noSubmit name="password" id="password" Value=""
bgcolor=#444444 text=#ffdd33 cursor=#cc9933
TYPE="password" ASCIIONLY
SIZE="${minisrv_config.config.passwords.form_size}"
MAXLENGTH="${minisrv_config.config.passwords.max_length}">
<tr>
<td height=6>
<tr>
<td colspan=3 align=left>
<br>Type again to confirm<br>
<INPUT noSubmit name="verify" id="verify" Value=""
bgcolor=#444444 text=#ffdd33 cursor=#cc9933
TYPE="password" ASCIIONLY
SIZE="${minisrv_config.config.passwords.form_size}"
MAXLENGTH="${minisrv_config.config.passwords.max_length}">
</a>
</table>
</table>
<td>
<tr>
<td absheight=7>
<tr>
<td>
<td colspan=2 absheight=2 bgcolor="2B2B2B">
<img src="wtv-home:/ROMCache/Spacer.gif" width=426 height=1>
<tr>
<td absheight=1>
<tr>
<td>
<td colspan=2 absheight=2 bgcolor="0D0D0D">
<img src="wtv-home:/ROMCache/Spacer.gif" width=426 height=1>
<tr>
<td absheight=4>
</table>
<table cellspacing=0 cellpadding=0>
<tr>
<td abswidth=430 valign=top align=right>
<font color="#E7CE4A" size=-1><shadow>
<input
selected
type=submit borderimage="file://ROM/Borders/ButtonBorder2.bif"
value=Done name="Done" usestyle width=103>
</shadow></font></form>
<td abswidth=20>
</table>
</body>
</html>
`;
}
}
if (userSession) userSession = null;

View File

@@ -0,0 +1,164 @@
var minisrv_service_file = true;
ssid_sessions[socket.ssid].loadSessionData();
var user_id = null;
if (request_headers.query.user_id) {
user_id = request_headers.query.user_id;
} else {
user_id = ssid_sessions[socket.ssid].user_id;
}
// security
if (ssid_sessions[socket.ssid].user_id != 0 && ssid_sessions[socket.ssid].user_id != request_headers.query.user_id) {
user_id = null; // force unset
var errpage = doErrorPage(400, "You are not authorized to edit the selected user.");
headers = errpage[0];
data = errpage[1];
}
if (user_id != null) {
headers = `200 OK
Connection: Keep-Alive
wtv-mail-count: ${ssid_sessions[socket.ssid].mailstore.countUnreadMessages(0)}
Content-Type: text/html`
var userSession = null;
if (ssid_sessions[socket.ssid].user_id == request_headers.query.user_id) userSession = ssid_sessions[socket.ssid];
else {
userSession = new WTVClientSessionData(minisrv_config, socket.ssid);
userSession.user_id = user_id;
}
if (!userSession.loadSessionData()) {
var errpage = doErrorPage(400, "Invalid user ID.");
headers = errpage[0];
data = errpage[1];
} else {
data = `
<HTML>
<HEAD>
<TITLE>
Changing ${(user_id == 0) ? 'subscriber' : 'user'} information
</TITLE>
<DISPLAY nosave
noscroll>
</HEAD>
<sidebar width=110> <table cellspacing=0 cellpadding=0 BGCOLOR="30364D">
<tr>
<td colspan=3 abswidth=104 absheight=4>
<td rowspan=99 width=6 absheight=420 valign=top align=left>
<img src="wtv-home:/ROMCache/Shadow.gif" width=6 height=420>
<tr>
<td abswidth=6>
<td abswidth=92 absheight=76>
<table href="wtv-home:/home" absheight=76 cellspacing=0 cellpadding=0>
<tr>
<td align=right>
<img src="${minisrv_config.config.service_logo}" width=87 height=67>
</table>
<td abswidth=6>
<tr><td absheight=5 colspan=3>
<table cellspacing=0 cellpadding=0>
<tr><td abswidth=104 absheight=2 valign=middle align=center bgcolor="1C1E28">
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
<tr><td abswidth=104 absheight=1 valign=top align=left>
<tr><td abswidth=104 absheight=2 valign=top align=left bgcolor="4D5573">
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
</table>
<tr><td absheight=37>
<tr><td absheight=263 align=right colspan=3>
<img src="ROMCache/AccountBanner.gif" width=53 height=263>
<tr><td absheight=41>
</table>
</sidebar>
<BODY BGCOLOR="#191919" TEXT="#44cc55" LINK="189CD6" VLINK="189CD6" HSPACE=0 VSPACE=0 FONTSIZE="large"
>
<table cellspacing=0 cellpadding=0>
<tr>
<td abswidth=14>
<td abswidth=416 absheight=80 valign=center>
<font size="+2" color="E7CE4A"><blackface><shadow>
${(user_id == 0) ? 'Subscriber' : 'User'} information
<td abswidth=20>
<tr>
<td>
<td absheight=244 valign=top align=left>
<form
action="wtv-setup:/serve-billing-overview"
>
<P>
<table cellspacing=0 cellpadding=0 border=0>
<tr>
<td align=left valign=top abswidth=198>
<table cellspacing=0 cellpadding=0>
<tr>
<td align=left>
Choose any item to
change the
information.
<p>Choose <b>Done</b> when
you're finished.
</a>
</table>
</td>
<td align=left valign=top width=6>
</td>
<td align=left valign=top abswidth=210>
<table cellspacing=0 cellpadding=0>
<tr>
<td colspan=3 align=left>
<b>Username:</b><br>
${userSession.getSessionData("subscriber_username")}
</a>
<tr>
<td height=6>
<tr>
<td colspan=3 align=left>
<b>Display Name:</b><br>
<a href="wtv-setup:/edit-user-name?user_id=${user_id}">
${userSession.getSessionData("subscriber_name")}
</a>
<tr>
<td height=6>
<tr>
<td colspan=3 align=left>
<b>Password:</b>
<br>
<a href="wtv-setup:/edit-password?user_id=${user_id}">
${(userSession.getUserPasswordEnabled()) ? "Change Password" : "Set Password"}
</a>
</table>
</table>
<td>
<tr>
<td absheight=7>
<tr>
<td>
<td colspan=2 absheight=2 bgcolor="2B2B2B">
<img src="wtv-home:/ROMCache/Spacer.gif" width=426 height=1>
<tr>
<td absheight=1>
<tr>
<td>
<td colspan=2 absheight=2 bgcolor="0D0D0D">
<img src="wtv-home:/ROMCache/Spacer.gif" width=426 height=1>
<tr>
<td absheight=4>
</table>
<table cellspacing=0 cellpadding=0>
<tr>
<td abswidth=430 valign=top align=right>
<font color="#E7CE4A" size=-1><shadow>
<input
selected
type=submit borderimage="file://ROM/Borders/ButtonBorder2.bif"
value=Done name="Done" usestyle width=103>
</shadow></font></form>
<td abswidth=20>
</table>
</body>
</html>
`;
}
}
if (userSession) userSession = null;

View File

@@ -0,0 +1,151 @@
var minisrv_service_file = true;
ssid_sessions[socket.ssid].loadSessionData();
var user_id = (request_headers.query.user_id) ? request_headers.query.user_id : ssid_sessions[socket.ssid].user_id;
// security
if (ssid_sessions[socket.ssid].user_id != 0 && ssid_sessions[socket.ssid].user_id != request_headers.query.user_id) {
user_id = null; // force unset
var errpage = wtvshared.doErrorPage(400, "You are not authorized to change the selected user's password.");
headers = errpage[0];
data = errpage[1];
}
if (user_id != null) {
var userSession = null;
if (ssid_sessions[socket.ssid].user_id == request_headers.query.user_id) userSession = ssid_sessions[socket.ssid];
else {
userSession = new WTVClientSessionData(minisrv_config, socket.ssid);
userSession.user_id = user_id;
}
if (!userSession.loadSessionData()) {
var errpage = wtvshared.doErrorPage(400, "Invalid user ID.");
headers = errpage[0];
data = errpage[1];
}
else {
headers = `200 OK
Connection: Keep-Alive
Content-Type: text/html`;
data = `
<HTML>
<HEAD>
<TITLE>
Changing your name
</TITLE>
<DISPLAY nosave
noscroll>
</HEAD>
<sidebar width=110> <table cellspacing=0 cellpadding=0 BGCOLOR="30364D">
<tr>
<td colspan=3 abswidth=104 absheight=4>
<td rowspan=99 width=6 absheight=420 valign=top align=left>
<img src="wtv-home:/ROMCache/Shadow.gif" width=6 height=420>
<tr>
<td abswidth=6>
<td abswidth=92 absheight=76>
<table href="wtv-home:/home" absheight=76 cellspacing=0 cellpadding=0>
<tr>
<td align=right>
<img src="${minisrv_config.config.service_logo}" width=87 height=67>
</table>
<td abswidth=6>
<tr><td absheight=5 colspan=3>
<table cellspacing=0 cellpadding=0>
<tr><td abswidth=104 absheight=2 valign=middle align=center bgcolor="1C1E28">
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
<tr><td abswidth=104 absheight=1 valign=top align=left>
<tr><td abswidth=104 absheight=2 valign=top align=left bgcolor="4D5573">
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
</table>
<tr><td absheight=37>
<tr><td absheight=263 align=right colspan=3>
<img src="ROMCache/AccountBanner.gif" width=53 height=263>
<tr><td absheight=41>
</table>
</sidebar>
<BODY BGCOLOR="#191919" TEXT="#44cc55" LINK="189CD6" VLINK="189CD6" HSPACE=0 VSPACE=0 FONTSIZE="large"
>
<table cellspacing=0 cellpadding=0>
<tr>
<td abswidth=14>
<td abswidth=416 absheight=80 valign=center>
<font size="+2" color="E7CE4A"><blackface><shadow>
Your name
<td abswidth=20>
<tr>
<td>
<td absheight=244 valign=top align=left>
<form
action="wtv-setup:/validate-change-name"
>
<P>
<table cellspacing=0 cellpadding=0 border=0>
<tr>
<td align=left valign=top abswidth=198>
<table cellspacing=0 cellpadding=0>
<tr>
<td align=left>
Change your display<br>
name here.
<p>Your name is<br>
included on your<br>
mail and news posts.<br>
<br>
Leave the field blank<br>
to set your display name to<br>
<b>${userSession.getSessionData('subscriber_username')}</b>.
</a>
</table>
</td>
<td align=left valign=top width=6>
</td>
<td align=left valign=top abswidth=210>
<table cellspacing=0 cellpadding=0>
<tr>
<td colspan=3 align=left>
Display name<br>
<INPUT noSubmit name="display_name" id="display_name" Value="${userSession.getSessionData('subscriber_name')}"
bgcolor=#444444 text=#ffdd33 cursor=#cc9933
TYPE="text" ASCIIONLY
SIZE="18"
MAXLENGTH="18">
<INPUT type="hidden" name="user_id" value="${user_id}">
</table>
</table>
<td>
<tr>
<td absheight=7>
<tr>
<td>
<td colspan=2 absheight=2 bgcolor="2B2B2B">
<img src="wtv-home:/ROMCache/Spacer.gif" width=426 height=1>
<tr>
<td absheight=1>
<tr>
<td>
<td colspan=2 absheight=2 bgcolor="0D0D0D">
<img src="wtv-home:/ROMCache/Spacer.gif" width=426 height=1>
<tr>
<td absheight=4>
</table>
<table cellspacing=0 cellpadding=0>
<tr>
<td abswidth=430 valign=top align=right>
<font color="#E7CE4A" size=-1><shadow>
<input
selected
type=submit borderimage="file://ROM/Borders/ButtonBorder2.bif"
value=Done name="Done" usestyle width=103>
</shadow></font></form>
<td abswidth=20>
</table>
</body>
</html>
`;
}
}
if (userSession) userSession = null;

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@@ -10,7 +10,7 @@ data = `
<HTML>
<HEAD>
<TITLE>
Your WebTV account
Your ${minisrv_config.config.service_name} account
</TITLE>
<DISPLAY noscroll>
</HEAD>
@@ -51,36 +51,28 @@ Your WebTV account
<tr>
<td valign=center absheight=80>
<font size="+2" color="E7CE4A"><blackface><shadow>
Your WebTV account
Your ${minisrv_config.config.service_name} account
</table>
<td abswidth=20>
<TR>
<td>
<td WIDTH=198 HEIGHT=236 VALIGN=top ALIGN=left>
<A HREF="JavaScript:alert('This feature is not available.')"><BLACKFACE>Subscriber info</BLACKFACE></A><BR>
<A HREF="wtv-setup:/edit-user-begin?user_id=0"><BLACKFACE>Subscriber info</BLACKFACE></A><BR>
<IMG SRC="wtv-home:/ROMCache/Spacer.gif" WIDTH=1 HEIGHT=1><BR>
<FONT SIZE="-1">Change your address, phone number, and password</FONT><BR>
<FONT SIZE="-1">Change your display name and/or password</FONT><BR>
<IMG SRC="wtv-home:/ROMCache/Spacer.gif" WIDTH=1 HEIGHT=11><BR>
<A HREF="JavaScript:alert('This feature is not available.')"><BLACKFACE>How you pay</BLACKFACE></A><BR>
<A HREF="wtv-setup:/accounts"><BLACKFACE>Additional Users</BLACKFACE></A><BR>
<IMG SRC="wtv-home:/ROMCache/Spacer.gif" WIDTH=1 HEIGHT=1><BR>
<FONT SIZE="-1">Change the way you pay for WebTV service</FONT><BR>
<IMG SRC="wtv-home:/ROMCache/Spacer.gif" WIDTH=1 HEIGHT=11><BR>
<A HREF="JavaScript:alert('This feature is not available.')"><BLACKFACE>ISP options</BLACKFACE></A><BR>
<IMG SRC="wtv-home:/ROMCache/Spacer.gif" WIDTH=1 HEIGHT=1><BR>
<FONT SIZE="-1">Save money if you dial long-distance to WebTV</FONT><BR>
<FONT SIZE="-1">Manage additional user accounts</FONT><BR>
<TD WIDTH=20>
<TD WIDTH=198 VALIGN=top ALIGN=left>
<A HREF="JavaScript:alert('This feature is not available.')"><BLACKFACE>Billing statement</BLACKFACE></A><BR>
<IMG SRC="wtv-home:/ROMCache/Spacer.gif" WIDTH=1 HEIGHT=1><BR>
<FONT SIZE="-1">For your account</FONT><BR>
<IMG SRC="wtv-home:/ROMCache/Spacer.gif" WIDTH=1 HEIGHT=11><BR>
<A HREF="wtv-home:/Credits-Legal"><BLACKFACE>Terms of service</BLACKFACE></A><BR>
<IMG SRC="wtv-home:/ROMCache/Spacer.gif" WIDTH=1 HEIGHT=1><BR>
<FONT SIZE="-1">Rules and regulations</FONT><BR>
<IMG SRC="wtv-home:/ROMCache/Spacer.gif" WIDTH=1 HEIGHT=11><BR>
<A HREF="wtv-home:/Credits-Privacy"><BLACKFACE>Privacy policy</BLACKFACE></A><BR>
<IMG SRC="wtv-home:/ROMCache/Spacer.gif" WIDTH=1 HEIGHT=1><BR>
<FONT SIZE="-1">Your personal information</FONT><BR>
<FONT SIZE="-1">How we use your personal information</FONT><BR>
<TR>
<TD>
@@ -102,7 +94,7 @@ Your WebTV account
<TR>
<TD>
<TD COLSPAN=3 VALIGN=top ALIGN=right>
<FORM action="client:goback">
<FORM action="wtv-setup:/setup">
<FONT COLOR="#E7CE4A" SIZE=-1><SHADOW>
<INPUT TYPE=SUBMIT BORDERIMAGE="file://ROM/Borders/ButtonBorder2.bif" Value=Done NAME="Done" USESTYLE WIDTH=103>
</SHADOW></FONT></FORM>

View File

@@ -86,11 +86,13 @@ for ${ssid_sessions[socket.ssid].getSessionData("subscriber_username") || "You"}
<img src="ROMCache/BulletArrow.gif" width=6 height=13 valign=absmiddle><spacer type=block width=6 height=1>
<a href="wtv-setup:/mail">Mail</a><BR>
<spacer type=block width=1 height=5><BR>`;
// password
if (!minisrv_config.config.hide_incomplete_features) {
data += `<img src="ROMCache/BulletArrow.gif" width=6 height=13 valign=absmiddle><spacer type=block width=6 height=1>
<a href="${notImplementedAlert}"><strike>Password</strike></a><BR>
if (minisrv_config.config.passwords) {
if (minisrv_config.config.passwords.enabled) {
data += `<img src="ROMCache/BulletArrow.gif" width=6 height=13 valign=absmiddle><spacer type=block width=6 height=1>
<a href="wtv-setup:/edit-password">Password</a><BR>
<spacer type=block width=1 height=5><BR>`;
}
}
data += `
@@ -114,10 +116,10 @@ data += `
<img src="ROMCache/BulletArrow.gif" width=6 height=13 valign=absmiddle><spacer type=block width=6 height=1>
<a href="wtv-setup:/keyboard">Keyboard</a><BR>
<spacer type=block width=1 height=5><BR>`;
// extra users
if (!minisrv_config.config.hide_incomplete_features) {
if (ssid_sessions[socket.ssid].user_id == 0) {
data += `<img src="ROMCache/BulletArrow.gif" width=6 height=13 valign=absmiddle><spacer type=block width=6 height=1>
<a href="${notImplementedAlert}"><strike>Extra users</strike></a><BR>
<a href="wtv-setup:/serve-billing-overview">Account</a><BR>
<spacer type=block width=1 height=5><BR>`;
}
@@ -130,13 +132,10 @@ data += `
<TD WIDTH=300 VALIGN=top ALIGN=left>
<spacer type=block width=6 height=14><font size="2"><br>
Signature <strike>and more</strike><BR>
<spacer type=block width=6 height=5><font size="2"><br>`;
// password
if (!minisrv_config.config.hide_incomplete_features) {
data += `<strike>Change your password</strike><BR>
<spacer type=block width=6 height=5><font size="2"><br>`;
}
data += `Options for your TV<BR>
<spacer type=block width=6 height=5><font size="2"><br>
Change your password<BR>
<spacer type=block width=6 height=5><font size="2"><br>
Options for your TV<BR>
<spacer type=block width=6 height=5><font size="2"><br>
Make text bigger or smaller<BR>
<spacer type=block width=6 height=5><font size="2"><br>
@@ -147,14 +146,13 @@ if (!minisrv_config.config.hide_incomplete_features) {
data += `<strike>Change how you print</strike><BR>
<spacer type=block width=6 height=5><font size="2"><br>`;
}
data += `Choose an on-screen keyboard<BR>
<spacer type=block width=6 height=5><font size="2"><br>`;
// extra users
if (!minisrv_config.config.hide_incomplete_features) {
data += `<strike>Add, change, or remove users</strike><BR>
<spacer type=block width=6 height=6><font size="2"><br>`;
data += `Choose an on-screen keyboard<BR>`;
if (ssid_sessions[socket.ssid].user_id == 0) {
data += `<spacer type=block width=6 height=5><font size="2"><br>
Add, change, or remove users<BR>`;
}
data += `
data += `<spacer type=block width=6 height=6><font size="2"><br>
Connecting to WebTV<BR>

View File

@@ -0,0 +1,63 @@
var minisrv_service_file = true;
var userSession = null;
var errpage = null;
if (ssid_sessions[socket.ssid].user_id != 0) errpage = wtvshared.doErrorPage(400, "You are not authorized to add users to this account.");
// seperate if statements as to not overwrite the first error if multiple occur
if (!errpage) {
if (request_headers.query.user_password) {
if (request_headers.query.user_password.length < minisrv_config.config.passwords.min_length) errpage = wtvshared.doErrorPage(400, "Your password must contain at least " + minisrv_config.config.passwords.min_length + " characters.");
}
else {
if (request_headers.query.user_password.length > minisrv_config.config.passwords.max_length) errpage = wtvshared.doErrorPage(400, "Your password must contain no more than than " + minisrv_config.config.passwords.max_length + " characters.");
else if (request_headers.query.user_password !== request_headers.query.user_password2) errpage = wtvshared.doErrorPage(400, "The passwords you entered did not match. Please check them and try again.");
}
}
if (!errpage) {
if (ssid_sessions[socket.ssid].getNumberOfUserAccounts() > minisrv_config.config.user_accounts.max_users_per_account) errpage = wtvshared.doErrorPage(400, "You are not authorized to add more than " + minisrv_config.config.user_accounts.max_users_per_account + " account${minisrv_config.config.user_accounts.max_users_per_account > 1 ? 's' : ''}.");
else if (!request_headers.query.user_name) errpage = wtvshared.doErrorPage(400, "Please enter a username.");
else if (!request_headers.query.display_name) request_headers.query.display_name = request_headers.query.username;
}
if (errpage) {
headers = errpage[0];
data = errpage[1];
} else {
userSession = new WTVClientSessionData(minisrv_config, socket.ssid);
var freeUserId = ssid_sessions[socket.ssid].findFreeUserSlot(ssid_sessions[socket.ssid]);
if (freeUserId) {
userSession.user_id = freeUserId;
userSession.setSessionData("subscriber_name", request_headers.query.display_name);
userSession.setSessionData("subscriber_username", request_headers.query.user_name);
userSession.setSessionData("registered", true);
mailstore_exists = userSession.mailstore.mailstoreExists();
if (!mailstore_exists) mailstore_exists = userSession.mailstore.createMailstore();
if (mailstore_exists) {
if (!userSession.mailstore.mailboxExists(mailbox)) {
// mailbox does not yet exist, create it
var mailbox_exists = userSession.mailstore.createMailbox(0);
if (mailbox_exists) {
// Just created Inbox for the first time, so create the welcome message
userSession.mailstore.createWelcomeMessage();
}
}
}
if (!userSession.saveSessionData(true)) {
var errpage = wtvshared.doErrorPage(400);
headers = errpage[0];
data = errpage[1];
} else {
if (request_headers.query.user_password)
userSession.setUserPassword(request_headers.query.user_password);
headers = `300 OK
Content-type: text/html
Location: wtv-setup:/accounts`;
}
}
}
if (userSession) userSession = null;

View File

@@ -0,0 +1,184 @@
var minisrv_service_file = true;
var errpage = null;
if (ssid_sessions[socket.ssid].user_id != 0) errpage = wtvshared.doErrorPage(400, "You are not authorized to add users to this account.");
// seperate if statements as to not overwrite the first error if multiple occur
if (!errpage) {
if (request_headers.query.user_password) {
if (request_headers.query.user_password.length < minisrv_config.config.passwords.min_length) errpage = wtvshared.doErrorPage(400, "Your password must contain at least " + minisrv_config.config.passwords.min_length + " characters.");
}
else {
if (request_headers.query.user_password.length > minisrv_config.config.passwords.max_length) errpage = wtvshared.doErrorPage(400, "Your password must contain no more than than " + minisrv_config.config.passwords.max_length + " characters.");
else if (request_headers.query.user_password !== request_headers.query.user_password2) errpage = wtvshared.doErrorPage(400, "The passwords you entered did not match. Please check them and try again.");
}
}
if (!errpage) {
if (ssid_sessions[socket.ssid].getNumberOfUserAccounts() > minisrv_config.config.user_accounts.max_users_per_account) errpage = wtvshared.doErrorPage(400, "You are not authorized to add more than " + minisrv_config.config.user_accounts.max_users_per_account + " account${minisrv_config.config.user_accounts.max_users_per_account > 1 ? 's' : ''}.");
else if (!request_headers.query.user_name) errpage = wtvshared.doErrorPage(400, "Please enter a username.");
}
if (errpage) {
headers = errpage[0];
data = errpage[1];
} else {
headers = `200 OK
Connection: Keep-Alive
Content-Type: text/html`
data = `<HTML>
<HTML>
<HEAD>
<TITLE>
Adding a user
</TITLE>
<DISPLAY nosave
noscroll>
</HEAD>
<sidebar width=110> <table cellspacing=0 cellpadding=0 BGCOLOR="30364D">
<tr>
<td colspan=3 abswidth=104 absheight=4>
<td rowspan=99 width=6 absheight=420 valign=top align=left>
<img src="wtv-home:/ROMCache/Shadow.gif" width=6 height=420>
<tr>
<td abswidth=6>
<td abswidth=92 absheight=76>
<table href="wtv-home:/home" absheight=76 cellspacing=0 cellpadding=0>
<tr>
<td align=right>
<img src="${minisrv_config.config.service_logo}" width=87 height=67>
</table>
<td abswidth=6>
<tr><td absheight=5 colspan=3>
<table cellspacing=0 cellpadding=0>
<tr><td abswidth=104 absheight=2 valign=middle align=center bgcolor="1C1E28">
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
<tr><td abswidth=104 absheight=1 valign=top align=left>
<tr><td abswidth=104 absheight=2 valign=top align=left bgcolor="4D5573">
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
</table>
<tr><td absheight=37>
<tr><td absheight=263 align=right colspan=3>
<img src="ROMCache/AccountBanner.gif" width=53 height=263>
<tr><td absheight=41>
</table>
</sidebar>
<BODY BGCOLOR="#191919" TEXT="#44cc55" LINK="189CD6" VLINK="189CD6" HSPACE=0 VSPACE=0 FONTSIZE="large"
>
<table cellspacing=0 cellpadding=0>
<tr>
<td abswidth=14>
<td abswidth=416 absheight=80 valign=center>
<font size="+2" color="E7CE4A"><blackface><shadow>
Adding a user
<td abswidth=20>
<tr>
<td>
<td absheight=244 valign=top align=left>
<form
action="/validate-add-user-done"
>
<P>
<table cellspacing=0 cellpadding=0 border=0>
<tr>
<td align=left valign=top abswidth=198>
<table cellspacing=0 cellpadding=0>
<INPUT TYPE="hidden" NAME="display_name" VALUE="${request_headers.query.display_name}">
<INPUT TYPE="hidden" NAME="user_name" VALUE="${request_headers.query.user_name}">
<INPUT TYPE="hidden" NAME="user_password" VALUE="${request_headers.query.user_password}">
<INPUT TYPE="hidden" NAME="user_password2" VALUE="${request_headers.query.user_password2}">
<tr>
<td align=left>
You are adding
<a href="wtv-setup:/add-user-name?
user-human-name-first=Joe&
user-human-name-last=blow&
user-name=xxxxxxx&
user-password=xxxx&
user-password2=xxxx&
restricted-web-access=unrestricted-access&
restricted-chat-access=unrestricted-access&
email-access-denied=&
cant-connect-past-cap=&
review-only='TRUE'">
${request_headers.query.user_name}<br>
</a>
to your account.
<tr>
<td height=11>
<tr>
<td align=left0 abswidth=198 maxlines=2>
Display Name:
<a href="wtv-setup:/add-user-name?
display_name=${request_headers.query.display_name}&
user_name=${request_headers.query.user_name}&
user_password=${request_headers.query.user_password}&
user_password2=${request_headers.query.user_password2}&
review-only='TRUE'">
${request_headers.query.display_name || request_headers.query.user_name}
</a>
<tr>
<td height=6>
<tr>
<td align=left abswidth=188 maxlines=2>
</table>
</td>
<td align=left valign=top width=6>
</td>
<td align=left valign=top abswidth=210>
<table cellspacing=0 cellpadding=0>
<input type=hidden name=display_name value="${request_headers.query.display_name}">
<input type=hidden name=user_name value="${request_headers.query.user_name}">
<input type=hidden name=user-password value="${request_headers.query.user_password}">
<input type=hidden name=user-password2 value="${request_headers.query.user_password2}">
<tr>
<td colspan=3 align=left>
<a href="wtv-setup:/add-user-password?
display_name=${request_headers.query.display_name}&
user_name=${request_headers.query.user_name}&
user_password=${request_headers.query.user_password}&
user_password2=${request_headers.query.user_password2}">`;
if ((request_headers.query.user_password) == "") {
data += `No password`;
} else {
data += `Has password`;
}
data += `
</a>
</table>
</table>
<td>
<tr>
<td absheight=7>
<tr>
<td>
<td colspan=2 absheight=2 bgcolor="2B2B2B">
<img src="wtv-home:/ROMCache/Spacer.gif" width=426 height=1>
<tr>
<td absheight=1>
<tr>
<td>
<td colspan=2 absheight=2 bgcolor="0D0D0D">
<img src="wtv-home:/ROMCache/Spacer.gif" width=426 height=1>
<tr>
<td absheight=4>
</table>
<table cellspacing=0 cellpadding=0>
<tr>
<td abswidth=430 valign=top align=right>
<font color="#E7CE4A" size=-1><shadow>
<input
selected
type=submit borderimage="file://ROM/Borders/ButtonBorder2.bif"
value=Done name="Done" usestyle width=103>
</shadow></font></form>
<td abswidth=20>
</table>
</body>
</html>
`;
}

View File

@@ -0,0 +1,39 @@
var minisrv_service_file = true;
ssid_sessions[socket.ssid].loadSessionData();
var user_id = (request_headers.query.user_id) ? request_headers.query.user_id : ssid_sessions[socket.ssid].user_id;
// security
if (ssid_sessions[socket.ssid].user_id != 0 && ssid_sessions[socket.ssid].user_id != request_headers.query.user_id) {
user_id = null; // force unset
var errpage = wtvshared.doErrorPage(400, "You are not authorized to change the selected user's password.");
headers = errpage[0];
data = errpage[1];
}
if (user_id != null) {
var userSession;
if (ssid_sessions[socket.ssid].user_id == request_headers.query.user_id) userSession = ssid_sessions[socket.ssid];
else {
userSession = new WTVClientSessionData(minisrv_config, socket.ssid);
userSession.user_id = user_id;
}
if (!userSession.loadSessionData()) {
var errpage = wtvshared.doErrorPage(400, "Invalid user ID.");
headers = errpage[0];
data = errpage[1];
}
else {
var user_name = userSession.getSessionData('subscriber_username');
userSession.setSessionData('subscriber_name', (request_headers.query.display_name) ? request_headers.query.display_name : user_name);
userSession.saveSessionData();
headers = `300 OK
Content-type: text/html
wtv-expire: wtv-setup:/edit-user-begin?user_id=${user_id}
wtv-expire: wtv-setup:/edit-user-name?user_id=${user_id}
Location: wtv-setup:/edit-user-begin?user_id=${user_id}`;
}
}
if (userSession) userSession = null;

View File

@@ -0,0 +1,75 @@
var minisrv_service_file = true;
var userSession = null;
ssid_sessions[socket.ssid].loadSessionData();
var user_id = null;
if (request_headers.query.user_id) {
user_id = request_headers.query.user_id;
} else {
var errpage = doErrorPage(400, "User was not specified.");
headers = errpage[0];
data = errpage[1];
}
if (ssid_sessions[socket.ssid].user_id != 0 && ssid_sessions[socket.ssid].user_id != request_headers.query.user_id) {
user_id = null; // force unset
var errpage = doErrorPage(400, "You are not authorized to edit the selected user.");
headers = errpage[0];
data = errpage[1];
}
if (user_id) {
headers = `200 OK
Connection: Keep-Alive
wtv-mail-count: ${ssid_sessions[socket.ssid].mailstore.countUnreadMessages(0)}
Content-Type: text/html`
var userSession = null;
if (ssid_sessions[socket.ssid].user_id == request_headers.query.user_id) userSession = ssid_sessions[socket.ssid];
else {
userSession = new WTVClientSessionData(minisrv_config, socket.ssid);
userSession.user_id = user_id;
}
if (!userSession.loadSessionData()) {
var errpage = doErrorPage(400, "Invalid user ID.");
headers = errpage[0];
data = errpage[1];
}
else {
if (request_headers.query.password.length == 0 && request_headers.query.verify.length == 0) {
userSession.disableUserPassword();
headers = `300 OK
Content-type: text/html
wtv-expire: wtv-setup:/setup
`;
if (request_headers.query.return_to) {
headers += `wtv-expire: ${request_headers.query.return_to}
Location: ${request_headers.query.return_to}`;
}
else headers += "Location: " + (ssid_sessions[socket.ssid].user_id === user_id) ? 'wtv-setup:/setup' : 'wtv-setup:/accounts';
}
else if (request_headers.query.password.length < minisrv_config.config.passwords.min_length) errpage = wtvshared.doErrorPage(400, "Your password must contain at least " + minisrv_config.config.passwords.min_length + " characters.");
else if (request_headers.query.password.length > minisrv_config.config.passwords.max_length) errpage = wtvshared.doErrorPage(400, "Your password must contain no more than than " + minisrv_config.config.passwords.max_length + " characters.");
else if (request_headers.query.password !== request_headers.query.verify) errpage = wtvshared.doErrorPage(400, "The passwords you entered did not match. Please check them and try again.");
else {
if (errpage) {
headers = errpage[0];
data = errpage[1];
} else {
userSession.setUserPassword(request_headers.query.password);
headers = `300 OK
Content-type: text/html
wtv-expire: wtv-setup:/setup
`;
if (request_headers.query.return_to) {
headers += `wtv-expire: ${request_headers.query.return_to}
Location: ${request_headers.query.return_to}`;
}
else headers += "Location: "+ (ssid_sessions[socket.ssid].user_id === user_id) ? 'wtv-setup:/setup' : 'wtv-setup:/accounts';
}
}
}
}
if (userSession) userSession = null;