So, small example. Make two different leaderboard examples. Change one of them to add the following, and also add grigio:babel and alanning:roles and nimble:restivus
// server/publications/players.es6
Meteor.publish('players', function () {
if Roles.userIsInRole(this.userId, 'view') {
return Players.find();
}
return [];
});
// client/templates/players.es6
Template.leaderboard.onCreated(function () {
this.autorun(() => {
let subscription = this.subscribe('players');
});
});
Okay, now on the other application, if one is running on http://localhost:3000 and one is running on http://localhost:3030, is it possible to create a connection between the two and get the players subscription?
Normally, the way to go is DDP.connect() but your subscription requires a logged in user, therefore you’d need to read through Connecting 2 apps over DDP, how to login across? to see what your options are, and you do have a couple of options, each with their own pros and cons.
Template.login.events({
'submit #login-form': function (e, template) {
let user = $(e.target).find('input#email').val();
let password = $(e.target).find('input#password').val();
Meteor.loginWithPassword(user, password, function () {
FlowRouter.go('/dashboard');
})
}
});