Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement