Compare commits

...
5 Commits
5 changed files with 15 additions and 29 deletions

No files matched your search

+6 -6
View File
@@ -1,13 +1,13 @@
var db = db.getSiblingDB('omdb'); var db = db.getSiblingDB('om');
// Delete all collections + all records // Delete all collections + all records
db.messages.deleteMany({}); //db.messages.deleteMany({});
db.tags.deleteMany({}); //db.tags.deleteMany({});
db.users.deleteMany({}); //db.users.deleteMany({});
db.sessions.deleteMany({}); //db.sessions.deleteMany({});
// Insert data in collections // Insert data in collections
load('mong_msg.js'); //load('mong_msg.js');
load('mong_tag.js'); load('mong_tag.js');
load('mong_usr.js'); load('mong_usr.js');
+2 -2
View File
@@ -1,8 +1,8 @@
db.users.insert([ db.users.insert([
// User: author, Pwd: author // User: author, Pwd: author
{"_id":"author","name":"Author","type":"MA@EFI;","roles":'{"user":true,"author":true}',"hash":"sha256","salt":"SIzKNsNKsCRVr8a9U90q6A==","pwd":"HZly68TSAKHioz6Kz0QCbXVTHpT6hMmabUbFYVlCMeE=","abos":["nulla","tempor","veniam","ipsum"],"bookmarks":[],}, {"_id":"author","name":"Author","type":"PF@EFI;","roles":'{"user":true,"author":true}',"hash":"sha256","salt":"SIzKNsNKsCRVr8a9U90q6A==","pwd":"HZly68TSAKHioz6Kz0QCbXVTHpT6hMmabUbFYVlCMeE=","abos":[],"bookmarks":[],},
// User: admin, Pwd: SwenMho // User: admin, Pwd: SwenMho
{"_id":"admin","name":"Test Admin","type":"MA@AMP;","roles":'{"user":true,"author":true,"admin":true}',"hash":"sha256","salt":"z3PNXGmQaWvaT7m2ZlT+0w==","pwd":"nfUfNv032J745xj3Hzya3Mkk43Dz/H0BmNTZhtx8UM0=","abos":["veniam","ipsum"],"bookmarks":[],}, // {"_id":"admin","name":"Test Admin","type":"MA@AMP;","roles":'{"user":true,"author":true,"admin":true}',"hash":"sha256","salt":"z3PNXGmQaWvaT7m2ZlT+0w==","pwd":"nfUfNv032J745xj3Hzya3Mkk43Dz/H0BmNTZhtx8UM0=","abos":["veniam","ipsum"],"bookmarks":[],},
]) ])
//var c = require('./server/crypto.js'), //var c = require('./server/crypto.js'),
+5 -5
View File
@@ -60,10 +60,10 @@ app.use(session({
secure: true, // true for https only (since our app works only with https) secure: true, // true for https only (since our app works only with https)
}, },
name: 'om.sid', name: 'om.sid',
store: new MongoStore({ // store: new MongoStore({
mongooseConnection: mong.connection, // mongooseConnection: mong.connection,
ttl: 30 * 24 * 3600, // ttl: 30 * 24 * 3600,
}), // mongoose + connect-mongo // }), // mongoose + connect-mongo
//store: new MemoryStore ({checkPeriod: 24*3600*1000}), // memorystore //store: new MemoryStore ({checkPeriod: 24*3600*1000}), // memorystore
})); }));
@@ -112,7 +112,7 @@ app.use('/api', api_routes);
app.use(express.static(__dirname + '/public')); app.use(express.static(__dirname + '/public'));
// Other stuff is NOT authorized unless logged in // Other stuff is NOT authorized unless logged in
app.use (authorize.genCheckAuthorized ('user')); //app.use (authorize.genCheckAuthorized ('user'));
// No error so far? Then it's a 404! // No error so far? Then it's a 404!
app.use(function (req, res, next) { app.use(function (req, res, next) {
+1 -1
View File
@@ -129,7 +129,7 @@ const authorization = {
if (entry != null && entry.pwd) { if (entry != null && entry.pwd) {
if (crypto.checkLocalAuth (entry, req.body.pwd)) { if (crypto.checkLocalAuth (entry, req.body.pwd)) {
console.info(entry.roles); console.info(entry.roles);
return fillSession (req, entry, JSON.parse(entry.roles), returnSession); return fillSession (req, entry, entry.roles, returnSession);
} }
return returnError (); return returnError ();
} }
+1 -15
View File
@@ -305,7 +305,7 @@ const dbs = {
* Local db: common.config.dbLocalConn * Local db: common.config.dbLocalConn
* TH db: common.config.dbConn * TH db: common.config.dbConn
*/ */
common.mongoose.connect(common.config.dbLocalConn, { common.mongoose.connect(common.config.dbConn, {
useNewUrlParser: true useNewUrlParser: true
}).then(() => { }).then(() => {
console.log("Database connected successfully."); console.log("Database connected successfully.");
@@ -386,18 +386,4 @@ const dbs = {
models: model, models: model,
}; };
/*
app.get ("/api/msg/search/:phrase", function (req, res) {
Message.find ({$text: {$search: req.params.phrase}) .then (function (err, results){
if (err) {
console.log (err);
res .status(404) .json (err);
} else {
console.log(JSON.stringify(results));
res.json(results);
}
});
});
*/
module.exports = dbs; module.exports = dbs;