Skip to content

Commit

Permalink
hacky/hellish cookie creation with session ID contained > relates #20
Browse files Browse the repository at this point in the history
  • Loading branch information
VirtualDOMinic committed Aug 16, 2018
1 parent d104c36 commit 33de2e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
19 changes: 14 additions & 5 deletions src/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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("<h1>Server Error in storeSession func</h1>");
} else {
res.writeHead(200, { "Content-Type": "text/html", "Set-Cookie": `session_id=${sssionID}` })
res.end("<h1>User added to database :)</h1>")
}
}
}
)}
)

// .then(
// (sessID) => {
// res.writeHead(200, { "Content-Type": "text/html", "Set-Cookie": `session_id='${sessID}'` })
// res.end("<h1>User added to database :)</h1>")
// }
// )
// .then()
// create cookie
// store session data
// all that jazz
res.writeHead(200, { "Content-Type": "text/html" });
res.end("<h1>User added to database :)</h1>");


}
);
});
Expand Down
2 changes: 1 addition & 1 deletion src/passwords.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const passwords = {
[sessionID, email],
(err, res) => {
if(err) return cb(err);
return cb(null, res);
return cb(null, res, sessionID);
}
)
}
Expand Down

0 comments on commit 33de2e7

Please sign in to comment.