ianmartorell / meteor-accounts-ui-bootstrap-3

accounts-ui package with Bootstrap 3 and localization support
150 stars 109 forks source link

Provide additional options for Accounts.onCreateUser #52

Closed ghost closed 9 years ago

ghost commented 9 years ago

Hi, I guess the title is self explained. So how can I pass some additional options values, which I then can validate on the server side. In my case, I need a affiliate userId which "gave" the link to this new user, so I can provide some points for the affiliate, or so. It would be cool to have some Hooks on the client side as well.

Thank you

ianmartorell commented 9 years ago

What about adding the referrer's id as a field in the newly created user so you can check it in onCreateUser?

ghost commented 9 years ago

hi ian, yes you are right, i could do it with a field, but the fields values are going to user.profile.. It's possible to solve, I know. However, just thought it would be cool to have some kind of Hook or Optional method, implemented by the user..

on lIne 477 instead of options = {};

var options = (typeof getCustomSignupOptions === 'function') getCustomSignupOptions() : {};
if (!(options instanceof Object)) options = {}

So then it's much simplier to pass some custom options values, just by creating these function on the client side..

getCustomSignupOptions = function() {
  return {
    refId: Session.get('refId') // Or whatever else..
  }
}

What do you think?

ianmartorell commented 9 years ago

I think it's a good idea! Sorry it took so long.

ghost commented 9 years ago

Thank you for implementing, I just updated the readme. https://github.com/ianmartorell/meteor-accounts-ui-bootstrap-3/pull/66

ianmartorell commented 9 years ago

Hey, I changed setCustomSignupOptions to accountsUIBootstrap3.setCustomSignupOptions for consistency.

ghost commented 9 years ago

Sure, it makes sense.