From 9e3981a7b1b2eda0b16433bebe104fbc5cd5a9b4 Mon Sep 17 00:00:00 2001 From: Erik Roemmelt Date: Wed, 24 Jul 2019 19:00:53 +0200 Subject: [PATCH] Demo:fix --- mong_usr.js | 2 +- server/authorization.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mong_usr.js b/mong_usr.js index 8747c8c..54c73b5 100644 --- a/mong_usr.js +++ b/mong_usr.js @@ -1,6 +1,6 @@ db.users.insert([ // User: author, Pwd: author - {"_id":"author","name":"Author","type":"PF@EFI;","roles":{"user","author"},"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 // {"_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":[],}, ]) diff --git a/server/authorization.js b/server/authorization.js index 0004b79..ebb7c2d 100644 --- a/server/authorization.js +++ b/server/authorization.js @@ -14,11 +14,11 @@ const clientVisibleSession = { user: true, name: true, type: true, mail: true, r // Return user role, query from found.mail function getUserRole(found) { - var roles = "user"; + var roles = "user:true"; var mail = found.mail; if (!/\d/.test(mail)) { // Mail contains no number - roles += ',"author"'; + roles += ',"author:true"'; } return ('{'+roles+'}'); }