Compare commits
14
Commits
master
...
9e3981a7b1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e3981a7b1 | ||
|
|
f727a5c44a | ||
|
|
1165918cd6 | ||
|
|
b891d8f516 | ||
|
|
0a3a45107a | ||
|
|
90c5362a57 | ||
|
|
675b9051dc | ||
|
|
e063535127 | ||
|
|
2686af2208 | ||
|
|
81e6a60def | ||
|
|
389a744ebe | ||
|
|
84e73466e1 | ||
|
|
31ba4a0b8b | ||
|
|
dda5e89990 |
No files matched your search
@@ -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
@@ -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'),
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ app.use(session({
|
|||||||
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
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Favicon for Desktop
|
// Favicon for Desktop
|
||||||
@@ -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) {
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ const clientVisibleSession = { user: true, name: true, type: true, mail: true, r
|
|||||||
|
|
||||||
// Return user role, query from found.mail
|
// Return user role, query from found.mail
|
||||||
function getUserRole(found) {
|
function getUserRole(found) {
|
||||||
var roles = "user";
|
var roles = "user:true";
|
||||||
var mail = found.mail;
|
var mail = found.mail;
|
||||||
if (!/\d/.test(mail)) {
|
if (!/\d/.test(mail)) {
|
||||||
// Mail contains no number
|
// Mail contains no number
|
||||||
roles += ',"author"';
|
roles += ',"author:true"';
|
||||||
}
|
}
|
||||||
return JSON.stringify('{'+roles+'}');
|
return ('{'+roles+'}');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill in session object
|
// Fill in session object
|
||||||
@@ -127,9 +127,9 @@ const authorization = {
|
|||||||
Users.findById (req.body.user) .exec (function (err, entry) {
|
Users.findById (req.body.user) .exec (function (err, entry) {
|
||||||
// If there is a local user AND it has a password associated, test against this, and only this
|
// If there is a local user AND it has a password associated, test against this, and only this
|
||||||
if (entry != null && entry.pwd) {
|
if (entry != null && entry.pwd) {
|
||||||
|
console.info(entry);
|
||||||
if (crypto.checkLocalAuth (entry, req.body.pwd)) {
|
if (crypto.checkLocalAuth (entry, req.body.pwd)) {
|
||||||
console.info(entry.roles);
|
return fillSession (req, entry, entry.roles, returnSession);
|
||||||
return fillSession (req, entry, JSON.parse(entry.roles), returnSession);
|
|
||||||
}
|
}
|
||||||
return returnError ();
|
return returnError ();
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ const authorization = {
|
|||||||
entry.type = found.type;
|
entry.type = found.type;
|
||||||
if (! entry.orclgender || entry.orclgender === "")
|
if (! entry.orclgender || entry.orclgender === "")
|
||||||
entry.orclgender = found.orclgender;
|
entry.orclgender = found.orclgender;
|
||||||
return fillSession (req, entry, entry.roles.length > 0 ? common.arrayToHash(entry.roles) : {user:true}, returnSession);
|
return fillSession (req, entry, entry.roles.length > 0 ? entry.roles : {user:true}, returnSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise create standard user entry
|
// Otherwise create standard user entry
|
||||||
|
|||||||
+1
-15
@@ -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;
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"dbConn": "mongodb://127.0.0.1:27017/om",
|
"dbConn": "mongodb://om:aeg1phuKeDaixese@127.0.0.1:27017/om",
|
||||||
"dbLocalConn": "mongodb://localhost:27017/omdb",
|
"dbLocalConn": "mongodb://localhost:27017/omdb",
|
||||||
"dbUser": "om",
|
"dbUser": "om",
|
||||||
"dbPwd": "aeg1phuKeDaixese",
|
"dbPwd": "aeg1phuKeDaixese",
|
||||||
|
|||||||
Reference in new issue
Block a user