I am converting a project from monolithic to microservice based architecture. The projects do not share database. Project-1 is auth, it handles all auth like login, signup, log out, while the project-2 is for product management, how should project-2 be aware of login and maintain, track the login state of a user?
You can remote login from project 2 at project 1 using a ddp-based login.
There are packages built for that purpose:
meteor package: https://github.com/reactioncommerce/meteor-ddp-login
npm package: https://github.com/vsivsi/ddp-login
Using a DDP connection you can remotely log in (freely taken from the forst package's README):
var conn = DDP.connect(Meteor.absoluteUrl());
DDP.loginWithPassword(conn, {username: 'admin'}, 'admin', function (error) {
// .... if no error you are free to go
})
Note that your project 2 will still need this connection (that holds the active authenticated logged in user) in order to make remote method calls or subscriptions to project 1.
Remote calls are done the same way as local ones but using this connection:
// call remote project's method
conn.call('methodName', params, callback)
// subscribe to remote project's publication
conn.subscribe('pubName', params)