Reputation: 4448
The application I'm building allows users to login using both their Facebook and Linkedin Accounts in order to fetch their friend from these networks. Each of their friend can be a user of the application.
I have a couple of problems to solve:
I'm using mongo (But am open to suggestions). So I though that i'd create a collection
of Users
where each user document looks like this:
User = {
appId: <id>,
connections: [userId]
}
So, each user has:
Should I unify users based on their email or name? or both?
I though that I could use LoginRadius but i was using singly just for that, and then they suddenly decided to kill the service. In other words, I don't want to depend on a third party tool because this is a core feature.
Upvotes: 4
Views: 381
Reputation: 2597
var UserSchema = new Schema({
name: { type: String, default: '' },
email: { type: String, default: '' },
provider: { type: String, default: '' },
hashed_password: { type: String, default: '' },
salt: { type: String, default: '' },
authToken: { type: String, default: '' },
facebook: {},
linkedin: {}
})
I'm using the Schema mentioned above for my users collection.
and when a new user wants to Sign up, using either the local strategy or social strategies
I just use the update mongoose function with the "upsert: true" option, to either update or
create an entry.
Upvotes: 1