2

I'm getting the following error:

TypeError: Object [object Object] has no method 'onCreateUser'
at app/server/accounts.js:1:45
at app/server/accounts.js:6:3

When calling Accounts.onCreateUser in a file named accounts.js in my server folder

Accounts.onCreateUser(function(options, user) 
{
     return user;
});

Please can someone help explain what i'm doing wrong?

First week with Meteor! :)

Luke Clifton
  • 81
  • 1
  • 8
  • Did you add any of the accounts packages? e.g. `meteor add accounts-password` – David Weldon Sep 16 '14 at 17:11
  • Yes accounts-password is added. Thanks for the response. – Luke Clifton Sep 16 '14 at 20:46
  • Did you add accounts-ui? To add Accounts and a set of login controls to an application, add the accounts-ui package and at least one login provider package: accounts-password, accounts-facebook, accounts-github, accounts-google, accounts-twitter, or accounts-weibo. – Walter Zalazar Sep 16 '14 at 23:21
  • Yes accounts-ui is also there. – Luke Clifton Sep 17 '14 at 06:51
  • This answer is what i'm trying achieve http://stackoverflow.com/a/22181816/2687165 But if i use this code i get the above error. Does this call back need to be wrapped in any specific code for it to work? – Luke Clifton Sep 17 '14 at 07:18
  • Try `console.log` the contents of `Accounts` object just before calling `onCreateUser` method. What do you see? – Tomasz Lenarcik Sep 17 '14 at 07:53

2 Answers2

1

Ok, embarrassing answer but thought i'd share in case any other newbies make the same mistake. I had created a collection with the name 'accounts' and this was causing a conflict and thus producing this error. I did not realise this was a reserved name in Meteor.

Luke Clifton
  • 81
  • 1
  • 8
0

Accounts depends the accounts-ui package,

A turn-key user interface for Meteor Accounts.

To add Accounts and a set of login controls to an application, add the accounts-ui package and at least one login provider package: accounts-password, accounts-facebook, accounts-github, accounts-google, accounts-twitter, or accounts-weibo.

http://docs.meteor.com/#accountsui

Walter Zalazar
  • 541
  • 4
  • 11