Fix accounts error handling

This commit is contained in:
Fabricio Nascimento
2016-05-18 15:27:39 -03:00
committed by Ben Newman
parent 72fb8690c0
commit e04d5f1ada

View File

@@ -1260,9 +1260,9 @@ Ap.insertUserDoc = function (options, user) {
// https://jira.mongodb.org/browse/SERVER-3069 will get fixed one day
if (e.name !== 'MongoError') throw e;
if (e.code !== 11000) throw e;
if (e.err.indexOf('emails.address') !== -1)
if (e.errmsg.indexOf('emails.address') !== -1)
throw new Meteor.Error(403, "Email already exists.");
if (e.err.indexOf('username') !== -1)
if (e.errmsg.indexOf('username') !== -1)
throw new Meteor.Error(403, "Username already exists.");
// XXX better error reporting for services.facebook.id duplicate, etc
throw e;