Thursday, April 10, 2014

Deployd - Adding an on "loggedin" event.

This is what I did to get a 'login' event working with deployd.  

There is most likely a better way to do this, but this is what I came up with.



The Gist:




First:

I added the:

UserCollection.events.push('Login');

line which added a new "event" to the entire system, even the dashboard for users now had a 'Login' tab.  However, the event still wasn't actually firing.


Next:


I did a search in the same 'user-collection.js' file for 'login' and found the part in the code where it actually logs a user in. Then I added the:

uc.events.Login.run(ctx);

line which is what actually runs the code I put in the users/events/login tab.


Note: I haven't done that much research into the eventing system, I have no valid reason for passing the ctx object in the run call, it was just the first argument in all the other event.run calls so I left it in :)

No comments:

Post a Comment