Merge pull request 'bind issue fixed' (#7) from cache-fix into master
Reviewed-on: #7
This commit is contained in:
commit
d34b74e505
@ -11,10 +11,6 @@ var userLUR = new LRUCache({
|
|||||||
maxAge: 60000,
|
maxAge: 60000,
|
||||||
});
|
});
|
||||||
|
|
||||||
const client = new Client({
|
|
||||||
url: conf.url,
|
|
||||||
});
|
|
||||||
|
|
||||||
const user_parse = function(data){
|
const user_parse = function(data){
|
||||||
if(data[conf.userNameAttribute]){
|
if(data[conf.userNameAttribute]){
|
||||||
data.username = data[conf.userNameAttribute];
|
data.username = data[conf.userNameAttribute];
|
||||||
@ -31,6 +27,10 @@ User.backing = "LDAP";
|
|||||||
|
|
||||||
User.list = async function(){
|
User.list = async function(){
|
||||||
try{
|
try{
|
||||||
|
const client = new Client({
|
||||||
|
url: conf.url,
|
||||||
|
});
|
||||||
|
|
||||||
await client.bind(conf.bindDN, conf.bindPassword);
|
await client.bind(conf.bindDN, conf.bindPassword);
|
||||||
|
|
||||||
const res = await client.search(conf.userBase, {
|
const res = await client.search(conf.userBase, {
|
||||||
@ -49,6 +49,10 @@ User.list = async function(){
|
|||||||
|
|
||||||
User.listDetail = async function(){
|
User.listDetail = async function(){
|
||||||
try{
|
try{
|
||||||
|
const client = new Client({
|
||||||
|
url: conf.url,
|
||||||
|
});
|
||||||
|
|
||||||
await client.bind(conf.bindDN, conf.bindPassword);
|
await client.bind(conf.bindDN, conf.bindPassword);
|
||||||
|
|
||||||
const res = await client.search(conf.userBase, {
|
const res = await client.search(conf.userBase, {
|
||||||
@ -86,7 +90,11 @@ User.get = async function(data, key){
|
|||||||
data.searchValue = data.searchValue || data.uid;
|
data.searchValue = data.searchValue || data.uid;
|
||||||
|
|
||||||
let filter = `(&${conf.userFilter}(${data.searchKey}=${data.searchValue}))`;
|
let filter = `(&${conf.userFilter}(${data.searchKey}=${data.searchValue}))`;
|
||||||
if(userLUR.get(filter)) return userLUR.get(filter)
|
if(userLUR.get(filter)) return userLUR.get(filter);
|
||||||
|
|
||||||
|
const client = new Client({
|
||||||
|
url: conf.url,
|
||||||
|
});
|
||||||
|
|
||||||
await client.bind(conf.bindDN, conf.bindPassword);
|
await client.bind(conf.bindDN, conf.bindPassword);
|
||||||
const res = await client.search(conf.userBase, {
|
const res = await client.search(conf.userBase, {
|
||||||
@ -131,6 +139,10 @@ User.login = async function(data){
|
|||||||
|
|
||||||
let user = await this.get(data.uid || data[conf.userNameAttribute] || data.username);
|
let user = await this.get(data.uid || data[conf.userNameAttribute] || data.username);
|
||||||
|
|
||||||
|
const client = new Client({
|
||||||
|
url: conf.url,
|
||||||
|
});
|
||||||
|
|
||||||
await client.bind(user.dn, data.password);
|
await client.bind(user.dn, data.password);
|
||||||
|
|
||||||
await client.unbind();
|
await client.unbind();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user