javascript - Account onLogin hook Meteor loop -


i building application using meteor. want create new cart id (to act cart can store items) each time user logs application. however, every time open new page in application, new cart id created. mean application "logs in" every single time click on new page in app? here's code:

    accounts.onlogin(function(user){             var newcartid = uuid.new()             meteor.users.update({_id: user.user._id}, {$set: {'profile.cartid': newcartid}})             console.log('just created new cart id @ ' + date());     }); 

yes, true.

every time open new page not logged in. when localstorage token authenticates you, similar how cookie does, logged in automatically. hook run when logged in automatically.

its difficult define how user logs in. meteor's onlogin hook fires on type of login method.

you can customise when want hook run, though:

accounts.onlogin(function(info) {      if(info.methodname == "createuser") {          console.log("this user logged in signing up");       }else if(info.type == "password") {          console.log("this user logged in using his/her password");       }else if(info.type == "resume") {          console.log("this user logged in using localstorage token");     } }); 

so here can make event fire when user logs in using or password. or when sign up. can use exclude running hook if user opens new page, uses localstorage token sign up.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -