Pass login type to client side Accounts.onLogin callbacks #9512
This PR adjusts client side
This approach should give developers a better way to respond to different client side login types, and act accordingly.
Client side `Accounts.onLogin` callbacks are triggered after a successful login, but they're also triggered after a successful DDP reconnect (if already logged in). As discussed in #5127, some people think this is the correct behaviour, while others feel that `onLogin` callbacks should really only fire after a user has actually logged in (e.g. after using something like `Meteor.loginWithPassword`). Since people are split on the proper approach here, an alternative solution would be to provide client side `Accounts.onLogin` callbacks with a way to tell if they're being called after a login or after a reconnect, then let them decide what to do. Server side `Accounts.onLogin` callbacks receive an object that contains various login details. One of those items is a login `type`, that can hold values like `password`, `resume`, etc. When a user completes a true password based login, the returned login `type` is `password`. When the user is already logged in but undergoes a DDP disconnect + reconnect, the returned login `type` is `resume`. This means server side `Accounts.onLogin` callbacks have a way to tell which type of login is happening, allowing them to respond accordingly. This PR adjusts client side `Accounts.onLogin` callbacks such that they also receive a single login details object, that contains login type information. Unlike the server side login details object, the client side login details object only contains the login type (to help reduce network transfer overhead, make sure we're not exposing server details on the client we shouldn't be, etc.). This approach should give developers a better way to respond to different client side login types, and act accordingly. Fixes #5127.