是否可以在Event发射器中传递For循环

时间:2014-01-30 12:32:03

标签: node.js events ldap eventemitter

在下面的代码中,如果我删除事件发射器部分,该功能正常工作(只有注释代码)。事件发射器我在这里做错了什么?我得到错误 TypeError:无法设置未定义属性'undefined'

function mapDetail(username, password, oauthToken, callback) {
    var eventEmitter = new events.EventEmitter();
    eventEmitter.on('completed', function (message) {
        if (message != "false"); {
        /* var key;
        this.users[key] = {username: username, password: password}
        for (key in this.users) {
            if (this.users[key] && this.users[key].username == username && this.users[key].password == password) {
                // Update the oauthToken document to signal that key is authenticated
                for (var otherKey in this.oauth_users_request_tokens) {
                    if (this.oauth_users_request_tokens[otherKey] && this.oauth_users_request_tokens[otherKey].token == oauthToken) {
                        this.oauth_users_request_tokens[otherKey].authenticated = true;
                        callback(null, this.oauth_users_request_tokens[otherKey]);
                        return;
                    }
                }
            }
        } */
        }
        else
        callback(new Error("Authentication of user/password failed"), null);
    });
    LDAPObj.userDetails(username, password, eventEmitter);
}


  

LDAPObj.userDetails是来自以下链接的代码   Node JS LDAP Auth User
  此代码我在以下场景中发出事件错误   eventEmitter.emit( '已完成', “假”);成功   eventEmitter.emit( '已完成', “真”);

0 个答案:

没有答案