RLG-Web: set up user directories on registration
Have RLG-Web create various user directories when a new user registers, as dgamelaunch does. Also add some debugging messages if registration fails.
This commit is contained in:
parent
e36f058daf
commit
2d86b63c98
1 changed files with 21 additions and 3 deletions
24
rlgwebd.js
24
rlgwebd.js
|
|
@ -327,6 +327,17 @@ function login(req, res, formdata) {
|
|||
return;
|
||||
}
|
||||
|
||||
/* Sets things up for a new user, like dgamelaunch's commands[register] */
|
||||
function regsetup(username) {
|
||||
function regsetup_l2(err) {
|
||||
for (var g in games) {
|
||||
fs.mkdir(path.join("/dgldir/ttyrec", username, games[g].uname), 0755);
|
||||
}
|
||||
}
|
||||
fs.mkdir(path.join("/dgldir/userdata", username), 0755);
|
||||
fs.mkdir(path.join("/dgldir/ttyrec/", username), 0755, regsetup_l2);
|
||||
}
|
||||
|
||||
function register(req, res, formdata) {
|
||||
var uname, passwd, email;
|
||||
if (typeof (formdata.name) != "string" || formdata.name === "") {
|
||||
|
|
@ -348,18 +359,25 @@ function register(req, res, formdata) {
|
|||
else
|
||||
email = formdata["email"];
|
||||
function checkreg(code, signal) {
|
||||
if (code == 4)
|
||||
if (code == 4) {
|
||||
sendError(res, 2, "Invalid characters in name or email.");
|
||||
else if (code == 1)
|
||||
console.log("Attempted registration: " + uname + " " + email);
|
||||
}
|
||||
else if (code == 1) {
|
||||
sendError(res, 2, "Username " + uname + " is already being used.");
|
||||
else if (code != 0)
|
||||
console.log("Attempted duplicate registration: " + uname);
|
||||
}
|
||||
else if (code != 0) {
|
||||
sendError(res, 0, null);
|
||||
console.log("sqlickrypt register failed with code " + code);
|
||||
}
|
||||
else {
|
||||
res.writeHead(200, {'Content-Type': 'text/plain'});
|
||||
var reply = {"t": "r", "d": uname};
|
||||
res.write(JSON.stringify(reply));
|
||||
res.end();
|
||||
console.log("Added new user: " + uname);
|
||||
regsetup(uname);
|
||||
}
|
||||
}
|
||||
var child_adder = child_process.spawn("/bin/sqlickrypt", ["register"]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue