Meteor.js on login event

后端 未结 2 1204
梦毁少年i
梦毁少年i 2021-02-04 03:42

So I\'m rather new to the meteor framework and JavaScript in general, but I\'m working on a little project using the framework to try and bring myself up to scratch. Basically I

相关标签:
2条回答
  • 2021-02-04 04:17

    I don't know if the way you're doing it is the most appropriate but personally do the following on the client side to detect if a user logged in:

    Tracker.autorun(function(){
      if(Meteor.userId()){
        //do your stuff
      }
    });
    
    0 讨论(0)
  • 2021-02-04 04:25

    If you are using google login or any other o-auth login, you can pass a callback function which will gets execute after login,

    Here is the sample code.

    Meteor.loginWithGoogle({
      requestPermissions: ['email']
    }, function(error) {
      if (error) {
        console.log(error); //If there is any error, will get error here
      }else{
        console.log(Meteor.user());// If there is successful login, you will get login details here
      }
    });
    
    0 讨论(0)
提交回复
热议问题