mirror of
https://github.com/mclueppers/xo-server.git
synced 2025-07-28 16:34:40 +02:00
Various updates
This commit is contained in:
parent
1a6aa64a1a
commit
222d008f3e
@ -277,7 +277,7 @@ Api.fn.user = {
|
|||||||
throw Api.err.INVALID_PARAMS;
|
throw Api.err.INVALID_PARAMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
var users = this.xo.users;
|
var users = this.xo.users;
|
||||||
return this.checkPermission(session, 'admin').then(function () {
|
return this.checkPermission(session, 'admin').then(function () {
|
||||||
return users.remove(p_id);
|
return users.remove(p_id);
|
||||||
}).then(function (success) {
|
}).then(function (success) {
|
||||||
|
72
src/collection/ldap.js
Normal file
72
src/collection/ldap.js
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* LDAP collection
|
||||||
|
* Copyright (C) 2013 Martin Dobrev <martin.dobrev@unixsol.co.uk>
|
||||||
|
* UNIXSOL LTD, registered company in UK and Wales
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @autor: Martin Dobrev <martin.dobrev@unixsol.co.uk>
|
||||||
|
**/
|
||||||
|
|
||||||
|
var _ = require('underscore');
|
||||||
|
var Q = require('q');
|
||||||
|
|
||||||
|
function LDAP(options, models)
|
||||||
|
{
|
||||||
|
if (!options)
|
||||||
|
{
|
||||||
|
options = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
_.defaults(options, {
|
||||||
|
'indexes': [],
|
||||||
|
});
|
||||||
|
|
||||||
|
LDAP.super_.call(this, models);
|
||||||
|
|
||||||
|
this.indexes = options.indexes;
|
||||||
|
this.prefix = options.prefix;
|
||||||
|
}
|
||||||
|
require('util').inherits(LDAP, require('../collection'));
|
||||||
|
|
||||||
|
// Private methods
|
||||||
|
LDAP.prototype._extract = function (ids)
|
||||||
|
{
|
||||||
|
console.log('Not yet implemented');
|
||||||
|
};
|
||||||
|
|
||||||
|
LDAP.prototype._get = function (properties)
|
||||||
|
{
|
||||||
|
console.log('Not yet implemented');
|
||||||
|
};
|
||||||
|
|
||||||
|
LDAP.prototype._add = function (models, options)
|
||||||
|
{
|
||||||
|
throw "Adding information to LDAP is not supported. You can manage the entries by other means."
|
||||||
|
};
|
||||||
|
|
||||||
|
LDAP.prototype._remove = function (ids)
|
||||||
|
{
|
||||||
|
throw "Removing information from LDAP is not supported. You can manage the entries by other means."
|
||||||
|
};
|
||||||
|
|
||||||
|
LDAP.prototype._update = function (models)
|
||||||
|
{
|
||||||
|
throw "Updating information from LDAP is not supported. You can manage the entries by other means."
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LDAP.extend = require('extendable');
|
||||||
|
module.exports = LDAP;
|
@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* @autor: Martin Dobrev <martin.dobrev@unixsol.co.uk>
|
* @author: Martin Dobrev <martin.dobrev@unixsol.co.uk>
|
||||||
**/
|
**/
|
||||||
|
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
@ -56,7 +56,7 @@ MySQL.prototype._extract = function (ids)
|
|||||||
var promises = [];
|
var promises = [];
|
||||||
|
|
||||||
_.each(ids, function (id) {
|
_.each(ids, function (id) {
|
||||||
promises.push(knex('users').where('email', id).andWhere('active', 1).select('password', 'email', 'permissions').then(function (model)
|
promises.push(knex('users').where('email', id).andWhere('active', 1).select('id', 'password', 'email', 'permissions').then(function (model)
|
||||||
{
|
{
|
||||||
if (_.isEmpty(model))
|
if (_.isEmpty(model))
|
||||||
{
|
{
|
||||||
@ -66,6 +66,7 @@ MySQL.prototype._extract = function (ids)
|
|||||||
var result =
|
var result =
|
||||||
{
|
{
|
||||||
id: id,
|
id: id,
|
||||||
|
db_id: model[0].id,
|
||||||
email: model[0].email,
|
email: model[0].email,
|
||||||
pw_hash: model[0].password,
|
pw_hash: model[0].password,
|
||||||
permission: perms[model[0].permissions],
|
permission: perms[model[0].permissions],
|
||||||
@ -193,7 +194,10 @@ MySQL.prototype._remove = function (ids)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @todo Handle indexes.
|
// @todo Handle indexes.
|
||||||
promises.push(knex('users').whereIn('email', keys).del());
|
promises.push(knex('users').whereIn('email', keys).del().then(function (ids)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}));
|
||||||
|
|
||||||
return Q.all(promises);
|
return Q.all(promises);
|
||||||
};
|
};
|
||||||
|
@ -356,7 +356,6 @@ cfg.merge({
|
|||||||
// Modified by Martin Dobrev @ 2013-10-22
|
// Modified by Martin Dobrev @ 2013-10-22
|
||||||
'mysql': {
|
'mysql': {
|
||||||
'enabled' : false,
|
'enabled' : false,
|
||||||
'uri' : 'mysql://xoauser:xoapass@localhost:3306/xoa',
|
|
||||||
'username' : 'xoauser',
|
'username' : 'xoauser',
|
||||||
'password' : 'xoapass',
|
'password' : 'xoapass',
|
||||||
'database' : 'xoa',
|
'database' : 'xoa',
|
||||||
|
@ -170,12 +170,12 @@ function InitializeUsersBackend(backend)
|
|||||||
case 'mysql' : collection = require('./collection/mysql'); break;
|
case 'mysql' : collection = require('./collection/mysql'); break;
|
||||||
case 'postgre' : break;
|
case 'postgre' : break;
|
||||||
case 'sqlite' : break;
|
case 'sqlite' : break;
|
||||||
case 'ldap' : break;
|
case 'ldap' : collection = require('./collection/ldap'); break;
|
||||||
default : throw "Userdb backend not supported: " + backend; break;
|
default : throw "Userdb backend not supported: " + backend; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collection !== null) {
|
if (collection !== null) {
|
||||||
console.info('UserDB initialized with %s backend', backend);
|
console.info('UserDB initialized with "%s" backend', backend);
|
||||||
|
|
||||||
return collection.extend({
|
return collection.extend({
|
||||||
'model': User,
|
'model': User,
|
||||||
@ -196,7 +196,7 @@ function InitializeUsersBackend(backend)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
throw "Unable to initialize UserDB Collection";
|
throw "Unable to initialize UserDB Collection. Using not yet implemented backend: " + backend;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user