From 33de2e7cf1f3f408e35ca7ff160c297e2212eafe Mon Sep 17 00:00:00 2001 From: Dominic Coelho Date: Thu, 16 Aug 2018 15:38:15 +0100 Subject: [PATCH] hacky/hellish cookie creation with session ID contained > relates #20 --- src/handlers.js | 19 ++++++++++++++----- src/passwords.js | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/handlers.js b/src/handlers.js index 3b743d7..b795caa 100644 --- a/src/handlers.js +++ b/src/handlers.js @@ -138,21 +138,30 @@ const handlers = { passwords.storeSession( sessionID, email, - (err, result) => { + (err, result, sssionID) => { console.log("Store Session func reached") if (err) { res.writeHead(500, { "Content-Type": "text/html" }); res.end("

Server Error in storeSession func

"); + } else { + res.writeHead(200, { "Content-Type": "text/html", "Set-Cookie": `session_id=${sssionID}` }) + res.end("

User added to database :)

") } - } + } )} ) - + // .then( + // (sessID) => { + // res.writeHead(200, { "Content-Type": "text/html", "Set-Cookie": `session_id='${sessID}'` }) + // res.end("

User added to database :)

") + // } + // ) + // .then() // create cookie // store session data // all that jazz - res.writeHead(200, { "Content-Type": "text/html" }); - res.end("

User added to database :)

"); + + } ); }); diff --git a/src/passwords.js b/src/passwords.js index 92b3db0..cf97225 100644 --- a/src/passwords.js +++ b/src/passwords.js @@ -33,7 +33,7 @@ const passwords = { [sessionID, email], (err, res) => { if(err) return cb(err); - return cb(null, res); + return cb(null, res, sessionID); } ) }