I’m making an app where a person can be part of multiple organizations. I’d like the person to be able to sign in with an email address and see all the organizations they have access to.
The person might have a different email address for each organization they have access to. They might also have one email address that is associated with multiple organizations.
What’s the best way to model this with Meteor’s Accounts?
Is it possible to have one Meteor.user
and use the emails
field to store the emails they can log in with? Then I suppose I’d need a way to associate one of their email addresses with their organization(s). Maybe something like this:
_id: ABC123,
emails: [
{address: jdoe@gmail.com, verified: true},
{address: john.doe@acme.com, verified: true}
],
organizations: [
{_id: orgA._id, email: jdoe@gmail.com, displayName: jdoe, profilePicture: url},
{_id: orgB._id, email: jdoe@gmail.com, displayName: jdoe, profilePicture: url},
{_id: orgC._id, email: john.doe@acme.com, displayName: john, profilePicture: url}
]
Or is it better to have a Meteor.user
for each email address they have and somehow allow them to link the user accounts? If so, how could you present a page where they can see all organizations for Meteor.user ABC123
and Meteor.user XYZ456
below:
_id: ABC123
emails: [
{address: jdoe@gmail.com, verified: true},
],
organizations: [_id: orgA._id, _id: orgB._id],
profile: {
displayName: jdoe,
profilePicture: url
}
_id: XYZ456
emails: [
{address: john.doe@acme.com, verified: true},
],
organizations: [_id: orgC._id],
profile: {
displayName: john,
profilePicture: url
}
Or maybe there’s another way that’s better than both ideas above…