I have one big application, with an admin side and a end-user side. I’ve had the ability for the admins to impersonate a user within the same broswer/tab for a long time now.
I’d now like to change it up a bit; I’d like the admin to be able to click the impersonate user button and be taken to a new tab and be logged in as that user in the new tab – but all the while the tab the admin came from must still be logged in as it was.
This is my impersonate user Meteor method:
'click #impersionate-user': (event, instance) => {
event.preventDefault();
if (Session.get('accountId')) {
Meteor.call('impersonate', Session.get('accountId'), (error, id) => {
if (error) throw new Meteor.Error(error);
Session.setPersistent('accountIdBeforeImpersionation', id); // persists accross page refresh
Meteor.connection.setUserId(id);
FlowRouter.go('user.dashboard.view');
});
}
}
});