diff --git a/README.md b/README.md index 5952a7a..cc0d784 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,9 @@ use blog_name; create table users( user_id mediumint unsigned not null AUTO_INCREMENT, -first_name varchar(20) not null, -last_name varchar(40) not null, user_name varchar(60) not null, -pass char(40) not null, -registration_date datetime not null, -admin boolean not null, +password char(64) not null, +salt char(64) not null, primary key(user_id) ); @@ -49,11 +46,12 @@ grant all on blog_name.* to blog_user@localhost identified by "password"; ## Node Dependencies ```bash npm install express -npm install client-sessions +npm install express-sessions npm install mysql npm install sanitizer npm install promise npm install markdown npm install markdown-to-html -g npm install highlight +npm install crypto ``` diff --git a/admin/admin.js b/admin/admin.js index 2eb011b..56bf32e 100644 --- a/admin/admin.js +++ b/admin/admin.js @@ -1,5 +1,6 @@ const utils = require('../utils/utils.js'); var Promise = require('promise'); +var session = require('client-sessions'); module.exports= { @@ -18,7 +19,7 @@ module.exports= { if(request.session && request.session.user) { - + console.log("user logged in"); utils.getPostData(request).then(function (postData) { return require("../admin/newPost.js").main(result, postData); @@ -34,7 +35,13 @@ module.exports= else { //login page - return require("../admin/login.js").main(result, request); + require("../admin/login.js").main(result, request).then(function() + { + resolve(); + }).catch(function(err) + { + console.log(err); + }) } }); diff --git a/admin/login.html b/admin/login.html index ca9d9df..996a747 100644 --- a/admin/login.html +++ b/admin/login.html @@ -1,14 +1,19 @@ -
").join("");
html = html.split("
").join("
");
res.write(html);
- console.log(html);
}
catch(ex)
{
diff --git a/server.js b/server.js
index cbd415e..816ef37 100644
--- a/server.js
+++ b/server.js
@@ -11,18 +11,13 @@ const url = require('url');
var express = require("express");
-var session = require('client-sessions');
+var session = require('express-session');
const includes = require('./includes/includes.js');
var app = express();
-app.use(session({
- cookieName: 'session',
- secret: 'random_string_goes_here',
- duration: 30 * 60 * 1000,
- activeDuration: 5 * 60 * 1000,
-}));
+app.use(session({ secret: 'keyboard cat', cookie: { maxAge: 6000000 }}));
app.use(function(request, res)
{
@@ -44,8 +39,6 @@ app.use(function(request, res)
var urlSplit = filename.split("/");
- console.log(urlSplit);
-
if(urlSplit.length >= 2 && urlSplit[1] === 'category') //single category page
file = "./posts/category.js";
@@ -55,8 +48,6 @@ app.use(function(request, res)
else
file = "./posts/posts.js";
- console.log(file);
-
includes.printHeader(res).then(function()
{
return require(file).main(res, filename, request);
@@ -65,7 +56,7 @@ app.use(function(request, res)
return includes.printFooter(res);
}).then(function()
{
- console.log("fin"); //for debugging
+ //console.log("fin"); //for debugging
})
}
diff --git a/sidebar/categoriesSideBar.js b/sidebar/categoriesSideBar.js
index 4ed3e53..b9f4421 100644
--- a/sidebar/categoriesSideBar.js
+++ b/sidebar/categoriesSideBar.js
@@ -12,7 +12,6 @@ module.exports=
*/
main: function(res)
{
- console.log("sidebar called");
return new Promise(function(resolve, reject)
{
res.write("