Login + Logout implemented; ProfilCard v1 implemented;

This commit is contained in:
2019-07-19 23:12:38 +02:00
parent 1fe9f22109
commit 5f0c8c1d2f
45 changed files with 2534 additions and 708 deletions
+10 -10
View File
@@ -3,13 +3,14 @@
/*
* Authorization
*/
var common, User;
var common, Users;
const ldap = require ('./ldap_ohm'),
crypto = require ("../server/crypto");
crypto = require ('./crypto'),
dbs = require ('./dbs');
// deactivated is not used yet
const serverVisibleSession = { user: true, name: true, type: true, mail: true, roles: true, deactivated: true, host: true };
const clientVisibleSession = { user: true, name: true, type: true, mail: true, roles: true };
const serverVisibleSession = { user: true, name: true, type: true, mail: true, roles: true, gender: true, deactivated: true, host: true };
const clientVisibleSession = { user: true, name: true, type: true, mail: true, roles: true, gender: true };
// Fill in session object
@@ -67,9 +68,9 @@ const authorization = {
return returnError();
return returnSession ();
}
/*
// check local database, then ldap
User.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 (entry != null && entry.pwd) {
if (crypto.checkLocalAuth (entry, req.body.pwd)) {
@@ -80,7 +81,7 @@ const authorization = {
// check ldap
ldap.authorize (user.toLowerCase(), pwd, function (found) {
console.log ("ldap authorize " + user + " returns " + JSON.stringify (found));
//console.log ("ldap authorize " + user + " returns " + JSON.stringify (found));
// No ldap entry either -> unauthorized
if (found == null) {
return returnError ();
@@ -100,7 +101,7 @@ const authorization = {
// Otherwise create standard user entry
return fillSession (req, found, {user:true}, returnSession);
});
});*/
});
},
logout: function (req, res, next) {
fillSession (req, undefined, undefined, function (err) {
@@ -110,9 +111,8 @@ const authorization = {
init: function (_common) {
common = _common;
ldap.init (_common);
//User = require('../database/user.model.js');;
Users = dbs.models.Users;
},
};
module.exports = authorization;
+2
View File
@@ -169,6 +169,8 @@ const dbs = {
console.log('Database connection error.');
process.exit();
});
// Default 'collection.ensureIndex' is deprecated; New is '.createIndexes'
common.mongoose.set('useCreateIndex', true);
/* DB Schemata
* Privat fields: