Demo: Update author role

This commit is contained in:
Erik Römmelt 2019-07-24 17:42:51 +02:00
parent 2686af2208
commit e063535127
3 changed files with 9 additions and 9 deletions

View File

@ -1,6 +1,6 @@
db.users.insert([ db.users.insert([
// User: author, Pwd: author // User: author, Pwd: author
{"_id":"author","name":"Author","type":"PF@EFI;","roles":'{"user":true,"author":true}',"hash":"sha256","salt":"SIzKNsNKsCRVr8a9U90q6A==","pwd":"HZly68TSAKHioz6Kz0QCbXVTHpT6hMmabUbFYVlCMeE=","abos":[],"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":[],},
]) ])

View File

@ -60,11 +60,11 @@ 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
})); }));
// Favicon for Desktop // Favicon for Desktop

View File

@ -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