Problems with 3rd party login services

I have integrated and properly configured Facebook and Twitter login, however they only work when this code is added:

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

If I remove the code above I am receiving the following error:
Exception while invoking method 'login' undefined

Any ideas why?

I also get the same error with the following code:

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

Fixed.

It was due to a validation error in the schema for profile.name