{"action":"created","issue":{"url":"https://api.github.com/repos/okland/accounts-phone/issues/18","labels_url":"https://api.github.com/repos/okland/accounts-phone/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/okland/accounts-phone/issues/18/comments","events_url":"https://api.github.com/repos/okland/accounts-phone/issues/18/events","html_url":"https://github.com/okland/accounts-phone/issues/18","id":124094007,"number":18,"title":"undefined _id after createUserWithPhone server-side","user":{"login":"clarkritchie","id":385550,"avatar_url":"https://avatars.githubusercontent.com/u/385550?v=3","gravatar_id":"","url":"https://api.github.com/users/clarkritchie","html_url":"https://github.com/clarkritchie","followers_url":"https://api.github.com/users/clarkritchie/followers","following_url":"https://api.github.com/users/clarkritchie/following{/other_user}","gists_url":"https://api.github.com/users/clarkritchie/gists{/gist_id}","starred_url":"https://api.github.com/users/clarkritchie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clarkritchie/subscriptions","organizations_url":"https://api.github.com/users/clarkritchie/orgs","repos_url":"https://api.github.com/users/clarkritchie/repos","events_url":"https://api.github.com/users/clarkritchie/events{/privacy}","received_events_url":"https://api.github.com/users/clarkritchie/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-28T17:22:24Z","updated_at":"2016-01-05T19:58:51Z","closed_at":"2016-01-05T19:58:51Z","body":"We're using `Accounts.createUserWithPhone` server-side so we can wrap it with necessary permission checks, add the user to necessary roles post-create, and so on.\r\n\r\nSimplified a little, our Meteor method pretty much boils down to this:\r\n\r\n```\r\ncreateUser: function(user) {\r\n    check(user, Object);\r\n\r\n    // assign a random password if none was specified\r\n    if (!user.password) {\r\n        user.password = Random.id();\r\n    }\r\n\r\n    // default profile.offers to true\r\n    user.profile.offers = true;\r\n\r\n    var id = Accounts.createUserWithPhone(user); // no callback on server\r\n    Roles.addUsersToRoles(id, 'users');\r\n    // can't return the _id, breaks the phone package callback\r\n}\r\n```\r\n\r\nThe documentation says no callback on the server.\r\n\r\nFor grins I wrapped `createUserWithPhone` in a try/catch and logged out the `_id`.\r\n\r\n```\r\n            try {\r\n                var id = Accounts.createUserWithPhone(user); // no callback on server\r\n            } catch(e) {\r\n                console.log(\"problem creating user: \", e);\r\n            }\r\n            console.log(\"User Created, _id: \", id);\r\n```\r\n\r\nI am seeing **a lot** of `undefined` values.\r\n```\r\nroot@mycoolserver:/var/log# cat mycoolapp.log | grep \"User Created\"\r\nUser Created, _id:  oftMAFFEhh2jdK9bc\r\nUser Created, _id:  undefined\r\nUser Created, _id:  undefined\r\nUser Created, _id:  undefined\r\nUser Created, _id:  undefined\r\nUser Created, _id:  xCj2HuMSS5rBSABuP\r\nUser Created, _id:  undefined\r\nUser Created, _id:  undefined\r\nUser Created, _id:  3rh5ti2Q8W6kcsrdM\r\nUser Created, _id:  7E5iBBi2hKN8bfvJG\r\nUser Created, _id:  oBN6HJAk5Yh6pZEox\r\nUser Created, _id:  undefined\r\nUser Created, _id:  undefined\r\n```\r\n\r\nAny thoughts?"},"comment":{"url":"https://api.github.com/repos/okland/accounts-phone/issues/comments/169112879","html_url":"https://github.com/okland/accounts-phone/issues/18#issuecomment-169112879","issue_url":"https://api.github.com/repos/okland/accounts-phone/issues/18","id":169112879,"user":{"login":"clarkritchie","id":385550,"avatar_url":"https://avatars.githubusercontent.com/u/385550?v=3","gravatar_id":"","url":"https://api.github.com/users/clarkritchie","html_url":"https://github.com/clarkritchie","followers_url":"https://api.github.com/users/clarkritchie/followers","following_url":"https://api.github.com/users/clarkritchie/following{/other_user}","gists_url":"https://api.github.com/users/clarkritchie/gists{/gist_id}","starred_url":"https://api.github.com/users/clarkritchie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clarkritchie/subscriptions","organizations_url":"https://api.github.com/users/clarkritchie/orgs","repos_url":"https://api.github.com/users/clarkritchie/repos","events_url":"https://api.github.com/users/clarkritchie/events{/privacy}","received_events_url":"https://api.github.com/users/clarkritchie/received_events","type":"User","site_admin":false},"created_at":"2016-01-05T19:58:51Z","updated_at":"2016-01-05T19:58:51Z","body":"OK I think there are/were two issues.\r\n\r\nClient side behavior in my app (users pressing enter on their phone vs. using the submit button) was sending incomplete data to my `createUser` method, which in turn called your `createUserWithPhone` with incomplete data.  I fixed that with stronger client side data validation on my end.\r\n\r\nI do think that `createUserWithPhone` was definitely not throwing an exception when it received incomplete data.  So perhaps stronger arg checking on your end?  I don't know, sort of swamped and can't test much right now.\r\n\r\nThanks for the package!  Over 2k verified users in our app."}}