How to integrate multiple social accounts for meteor account modules in 2017

[Mobile version(QRCode)] Total views:69,200 / Applauds for blog:1
Welcome to my page. I am an adminisrator of this site.
If you are this db's user, please contact with me by private mail. If not, please contact with me by email or twitter or facebook
Access record[Graph / PV Info.(Past 1 day / Past 1 week) / Access from outside (Yesterday / Past 1 week) / Vistors's list]
ProfilePmail(Mail)
Inbox   /Send   /Sent
Reviews(List   /Limit)
Poll   /Agree:Got   /Sent
Fan
Works/Music
Blog
[Write]
Links
My Play List
<=Newer article Tips
=>Older article How to create offline app using metoer

1.
2017/04/15 "Meteor > How to integrate multiple social accounts for meteor account modules in 2017"
[Show only this article / Modify / Delete / Send trackback / Add to the shared category]

Methodology and modules are outdated about how to integrate with multiple social accounts for meteor.js.
I managed to find the way about how to do it.

Add the following code to server side's script.
Accounts.onCreateUser(function(options, user) {
        if (user.services) {
            var service = _.keys(user.services)[0];
            var email = user.services[service].email;

// define trustable service 
            if (service == 'github' || service == 'facebook' || service == 'twitter' || service == 'google') {
                if (!user.profile)
                    user.profile = {};
                if (!user.profile.name)
                    user.profile.name = user.services[service].username;
            }
 
            if (!email)
                return user;
 
            // see if any existing user has this email address, otherwise create new
            var existingUser = Meteor.users.findOne({'emails.address': email});
            if (!existingUser)
                return user;
            console.log(user.services);
 
            // precaution, these will exist from accounts-password if used
            if (!existingUser.services)
                existingUser.services = { resume: { loginTokens: [] }};
            if (!existingUser.services.resume)
                existingUser.services.resume = { loginTokens: [] };
 
            // copy across new service info
            existingUser.services[service] = user.services[service];
            existingUser.services.resume.loginTokens.push(
                //user.services.resume.loginTokens[0]
                user.services[service].accessToken
            );
 
            // even worse hackery
            Meteor.users.remove({_id: existingUser._id}); // remove existing record
            return existingUser;                          // record is re-inserted
        }
    });

I modified
http://www.meteorpedia.com/read/Merging_OAuth_accounts
because there are some parts which I cannot use as it is but this helped me to reach this solution.
Red parts are the parts which I modified.

Add comment to this article


[Read other articles]
<=Newer article Tips
=>Older article How to create offline app using metoer


Articles categorized as "Meteor by this user"
All articles of this user
Subscribe to RSS
RSS
Term
Category
All
1.Japan
2.Atlassian's products
3.Self
4.Development of this site
5.Japanese comics
6.Japanese anime
7.Weekly hot news of Japanese culture
8.OP/ED/PV
9.Japanese game
10.Ranking
11.Japanese Comics (Manga)
12.Search Engine
13.Japanese drama
14.Japanese otaku culture
15.Programming
16.Ineternet world
17.Movie
18.C/C++
19.BerkeleyDB
20.Apache programming
21.Spam
22.Meteor
23.Marketing
24.Python
25.Scrum
26.JIRA
27.Git
28.CI
29.Jenkins
30.AWS
31.Operation
32.Singapore
33.Cloud
34.Mysql Cluster
35.DevOps
36.Bitbucket
37.Xamarin
38.Good and new
39.Monitoring
40.JavaScript(node.js)
41.React
42.Phillipines
43.Hiring
44.Python
45.SEO
46.Malaysia
47.Mongodb
48.Perl
49.Docker
50.Life hack
51.Dance
52.QA
53.Mysql
54.Digital Life Hack
55.Project management
56.Django
57.Gatsby
58.Administrator
Sayings from S-Cry-Ed

Rule in this world is speed. Even stupid person can write cool novel if he can spend 20 years for it.

If someone helped me, I will help him in return, which is my rule.

To become stronger, consider what is cowardliest thinking. And rebel against the thinking, which will make you stronger.



I am Japanese but working for some English sites.

Doctor Job Career
Nurse Job Career
↑Top