Browse Source

Only setup/call ldap methods if enabled

master
Travis Burtrum 6 years ago
parent
commit
fb479eed71
2 changed files with 10 additions and 1 deletions
  1. +3
    -0
      clientapp/models/ldapUsers.js
  2. +7
    -1
      server.js

+ 3
- 0
clientapp/models/ldapUsers.js View File

@ -24,6 +24,7 @@ module.exports = BaseCollection.extend({
fetch: function (cb) {
var self = this;
if(SERVER_CONFIG.ldapEnabled)
$.post('/ldap/users', ldapUser.ldapData(), function(users) {
var toRemove = [];
for ( var i = 0; i < self.models.length; i++) {
@ -52,6 +53,7 @@ module.exports = BaseCollection.extend({
addUser: function (id) {
var self = this;
if(SERVER_CONFIG.ldapEnabled)
$.post('/ldap/users/add', ldapUser.ldapData({newUid: id}), function(result) {
result = JSON.parse(result);
if (result) {
@ -62,6 +64,7 @@ module.exports = BaseCollection.extend({
deleteUser: function (id) {
var self = this;
if(SERVER_CONFIG.ldapEnabled)
$.post('/ldap/users/delete', ldapUser.ldapData({removeUid: id}), function(result) {
result = JSON.parse(result);
if (result) {


+ 7
- 1
server.js View File

@ -8,6 +8,8 @@ var templatizer = require('templatizer');
var async = require('async');
var LDAP = require('ldapjs');
config.ldapEnabled = !(!config.ldap || !config.ldap.address || !config.ldap.base);
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
};
@ -50,9 +52,11 @@ app.get('/sounds/*', function (req, res) {
res.redirect("./public" + req.baseUrl);
});
if (config.ldapEnabled) {
function connectLDAP(req, cb) {
if (!config.ldap || !config.ldap.address || !config.ldap.base) {
if (!config.ldapEnabled) {
cb(true);
return;
}
@ -298,6 +302,8 @@ app.post('/ldap/users/delete', function (req, res) {
});
}
app.get('/oauth/login', function (req, res) {
res.redirect('https://apps.andyet.com/oauth/authorize?client_id=' + config.andyetAuth.id + '&response_type=token');
});


Loading…
Cancel
Save