Skip to content

Instantly share code, notes, and snippets.

@mackbrowne
Last active June 19, 2017 15:09
Show Gist options
  • Save mackbrowne/30317eba75d13683566ead357b52bbce to your computer and use it in GitHub Desktop.
Save mackbrowne/30317eba75d13683566ead357b52bbce to your computer and use it in GitHub Desktop.
Accounts Meteor Link Hack
Accounts.onCreateUser((options, user) => {
user.city = null;
user.networks = [];
user.attending = [];
if (user.profile == null) {
user.profile = {};
}
if (user.services != null) {
var service = _.keys(user.services)[0];
var email = user.services[service].email;
if (email != null) {
var oldUser = Meteor.users.findOne({
"emails.address": email
});
if (oldUser != null) {
if (oldUser.services == null) {
oldUser.services = {};
}
if (service === "google" || service === "facebook" || service === "twitter") {
oldUser.services[service] = user.services[service];
Meteor.users.remove(oldUser._id);
user = oldUser;
}
} else {
if (service === "google" || service === "facebook" || service === "twitter") {
if (user.services[service].email != null) {
user.emails = [{
address: user.services[service].email,
verified: true
}];
} else {
throw new Meteor.Error(500, service + " account has no email attached");
}
user.profile.name = user.services[service].name;
}
}
}
}
return user;
});
@mackbrowne
Copy link
Author

@mackbrowne
Copy link
Author

Put in Server code

Make sure all email verification is mandatory on all accounts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment