Closed steph643 closed 9 years ago
I'd say with an observeChanges
I would prefer to avoid a client-side observer on (hopefully) the biggest collection of my application :-)
I will rather try to add my own Accounts.onLogin
hook. Do you know how to be sure my hook gets called after yours?
...it might also be that you don't publish the whole users collection to your client ;-)
Kidding apart,
package code is loaded before the top level code of your app, so any onLogin
hook you set up should come after the ones set by packages.
It works, thanks.
To people who might need this in the future, notice that there is a minor inconvenience when adding your on onLogin hook: when a user logs-in for the first time, the info.user
argument does not contain the registered_emails
field. So you will need to load it like this:
Accounts.onLogin(function (info) {
// Get the user (if login was successful)
var user = info.user;
if (! user)
return;
// Get the registered_emails that the meteor-accounts-emails-field package has just set
user = Meteor.users.findOne(user._id, { fields: { registered_emails: 1, ... } });
check(user.registered_emails, [Object]);
...
});
oh, right!
this is actually needed all the time, since modification to the info
object are not propagated through different onLogin
callbacks!
I also had to do the same for accounts-meld
: see these lines
Could you prepare a simple PR to add something about this into the README?
Ok, I will have a look.
Done, tnx!
I keep, in
Meteor.users
, anofficialContactEmail
field which I need to update wheneverregistered_emails
changes. How can I do that?