feat 4571 Replace all Meteor.userId() with util function #4582
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #4571
Impact: minor
Type: chore
Issue
Goal: As a first step towards being able to replace Meteor's Accounts package, we want to wrap all existing calls to Meteor.userId in a function. Thus establishing an 'API' to retrieve logged in user ID that can be customized in the future.
Work
Added of a getUserId() function on the client and server exports of
Reaction
namespace. It returns the value of Meteor.userId().Replaces all usage of Meteor.userId() with Reaction.getUserId()
Marked existing
reaction/getUserId
method as deprecated. Reaction.getUserId should be used insteadExtras
getGuestLoginState
function that was marked for removal in release 1.5.6. It was removed here as it uses the Meteor.userId method we're moving from.Breaking changes
Core functionality of the app is untouched, but here's a potentially breaking update:
getGuestLoginState
. This is/was an internal function, but in case anyone has plugin(s) using it, please update. This logic in this function can be recreated with theRoles
package if needed.A note to Plugin maintainers:
Meteor.userId
directly in your code.getUserId()
should be used instead. Although this is not a breaking change as your existing plugins withMeteor.userId()
will still work, this marks Reaction's initial set of steps to move away from Meteor accounts system. In coming releases, the internal setup ofgetUserId()
will change. When that happens it will be listed as a breaking change for you to take note.Testing