how to use everyauth.password over sockets / rpc

125 views
Skip to first unread message

Davis Ford

unread,
Apr 15, 2012, 9:16:14 PM4/15/12
to ever...@googlegroups.com
Hi, I'm building an app with socket.io, and I want to handle password auth over sockets -- not HTTP; 

I'm using everyauth, and then I added mongo, so I added mongoose-auth, and the various OAuth providers work fine for me (e.g. twitter) -- but they do require HTTP and that is fine...

Now, I just want to call my own server-side rpc method and pass the username/password -- I can't seem to resolve how to just use mongoose-auth (or everyauth for that matter) as just a library API -- as opposed to middleware that only fires with app.post('/login')

If I do a form POST on button submit, then everyauth chokes b/c I don't have all it's properties defined for login view, register view, etc. and all that... I don't want to configure any of that, b/c it does not match my application.

I think the methods are in there to do this, but they seem buried in the objects -- especially since mongoose-auth wraps everyauth adding yet another layer of abstraction, and so far my attempts  have not succeeded....something like this:

// this is server side RPC method that is called over sockets, passing user's email and password...I basically tried copying the simplest thing that might work from the everyauth or mongoose-auth source =>

login: function (email, pass) {
  User()().authenticate(email, pass, function (err, user) {
   if (err) {
    res(false, "Login failed: "+err);
    return;
   } 
  if (!user) {
    res(false, "User not registered");
    return;
    }
    res(true);
  });
}

when executed, this is giving me a type error: -- 

TypeError: Object #<Object> has no method 'setMaxListeners' at Document (/../node_modules/mongoose/lib/document.js:30:8) at Model (/../node_modules/mongoose/lib/model.js:26:12) at model (/../node_modules/mongoose/lib/model.js:894:11) at Function.<anonymous> (/../server/rpc/auth.js:16:4) ...

Nicola G.

unread,
Jun 5, 2012, 5:49:50 AM6/5/12
to ever...@googlegroups.com
UP!
Reply all
Reply to author
Forward
0 new messages