hashedToken and meteor accounts questions


I registered a custom login handler, sort of like https://meteorhacks.com/extending-meteor-accounts but I didn’t do anything with the hashed login tokens as that example mentions.

I see however, that I’m getting in my Users collection, a services.resume.loginToken structure, with a few tokens. On any day, it seems like there are a few tokens from the day before. But if I do a proper logout, the token from today goes away.

I’m wondering if there’s a way to get the current loginToken for the current login session.

I’ve found I can do this in a helper:

return Meteor.user().services.resume.loginTokens[0].hashedToken;

but of course, that gives me the first one in the array, and the most recent one is not necessarily the first one in the array, if there are others in there from the day prior.

update: I also found various references to this:


but this does not run on the client in a helper…


Solved it, when I thought about it like an array:


This gives me the last element in the array of resume tokens, using the length - 1 as the index. Works, but I still wonder if there’s a better way.

Also, this only works if the most recent token is added to the end of this array, which I think is a safe assumption.