authentication against XMPP

47 views
Skip to first unread message

Gonzalo Amadio

unread,
Jul 18, 2014, 3:12:01 PM7/18/14
to nod...@googlegroups.com
Hello.

I want to make a loguin function, that checks users against a XMPP server. So far I am doing something similar with IMAP and emails.
And I want to change loguin against XMPP.  

Here is my function, with Imap. Can you helpm me with xmpp ? Thanks!


**
* Loguin function with IMAP, if there is a user with that email, call succesCB, if not, failCB.
* @method checkPassword
* @param name {string} Email id
* @param server {string} Email server
* @param password {string} Password
* @param successCB {function} If loguin was successful, call successCB(name)
* @param errorCB {function} If loguin was not  successful, call failCB(name)
*/

function checkPassword(userName, server, password, successCB, failCB) {


    var uName = userName + "@" + server;
    var hostName;
    var portNumber;
    var tlsEnable;
    
       var imap = new Imap({
      user: uName,
      password: password,
      host: hostName,
      port: portNumber,
      tls: tlsEnable,
      tlsOptions: { rejectUnauthorized: false }
    });

    function openInbox(cb) {
      imap.openBox('INBOX', true, cb);
    }

    imap.once('ready', function() {
        console.log(uName + "Authenticated");
        successCB(uName);
        imap.end();
    });

    imap.once('error', function(err) {
        console.log(uName + "Not authenticated");
        failCB("Wrong Login, try again",1);
    });

    imap.once('end', function() {
        console.log('Closing IMAP.');
    });

    imap.connect();
    
}


Thanks!!
Reply all
Reply to author
Forward
0 new messages