how can I know that before loopback-component-passport login or create?

28 views
Skip to first unread message

陳宏圖

unread,
May 27, 2015, 6:21:41 AM5/27/15
to loopb...@googlegroups.com

for example: if I wanna do something after loopback-component-passport create the user, 
and do other thing before the user login
I thought I can use remote hooks to get the timing I want.
like:

MyUser.afterRemote('create', function(context, instance, next) {
    // do something here
    next();
  });

  MyUser.beforeRemote('login', function(context, instance, next) {
    // do something here
    next();
  });

I found out it didn't work.

so I use operation hook

MyUser.observe('after save', function(ctx, next) {
    if (ctx.instance) {
      // I can know it's a newly created user
    } else {
     // otherwise...
    }
    next();
  });

But I still can't get any hint about when I can access before user login?

Did I miss something, or anyone has a better idea about doing the other way?

Diddn't loopback-component-passport use User.login, User.create?

Reply all
Reply to author
Forward
0 new messages