Multiple accounts with same emails


#1

I’m making an App where you can create two kinds of profiles, Public and Private, and you can use both profiles at the same time. To accomplish this you can use the same email to sign up, and then you can switch between profiles when you are logged in. At the moment Accounts-Base doesn’t allow to make this, because I’m using the same email to register another profile. Is there some kind of approach to accomplish this? Thanks for the time, any help would be great.


#2

Will it be two different accounts? You cannot be logged in to both at the same time anyway. I think you need to describe what you are after a bit more


#3

You would probably want to create two MongoDB collections, one for public profiles, and one for private profiles. Both are linked by the same userId and share the same login token.


#4

You can use a “roles” concept to achieve a similar affect. alanning:roles can bootstrap you with roles quite fast. Basically one role uses one part of the profile object and other role uses the other part. And you pubish the relevant part of the user profile based on the context.

Edit:
This does not have to be roles, though I think it makes the concept easier to grasp/mange. You can just as well use a “activeContext/activeProfile” identifier somewhere in your app and use that to signal which profile the user should operate with.


#5

Not at the same time, but with the same email. For example, when I access to the App (Login form), I automatically go to my Private Profile, but inside this profile I can switch to my Public Profile, previously registered with the same email.


#6

…and log in again, enter your password again? You know you can have one public and one private profile to the same account? To me it sounds like big trouble to have two accounts connected like that, they will have different userId, it will be, in all important aspects, two accounts.


#7

Yes, two accounts after all, but with no necessary login when you are logged in one of them. I will check creating just another collection with no register form, just linked with the user ID.


#8

One way, without messing with the actual account data, is that you have a Profile collection,

{
userId: String;
publicProfile: Object
privateProfile: Object
}

Then, to switch, you have a method that basically do something like

Meteor.users.update( {_id:this.userId}, {$set: {profile: Profiles.findOne({userId: this.userId}).publicProfile}} )


#9

Thanks Ralof, this seems a good idea to start with.