Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Meteor Accounts.onLogin无限循环_Javascript_Meteor_Meteor Accounts - Fatal编程技术网

Javascript Meteor Accounts.onLogin无限循环

Javascript Meteor Accounts.onLogin无限循环,javascript,meteor,meteor-accounts,Javascript,Meteor,Meteor Accounts,在Meteor论坛中,我读到建议将Meteor.logootherclients放在Accounts.onLogin()中。虽然这是可行的,但有一个问题,那就是当打开多个选项卡(不是浏览器)时,Accounts.onLogin()会被多次调用。这是预期产出吗 下面是我的代码: Accounts.onLogin(() => { console.log('onLogin called') Meteor.logoutOtherClients((error) => { if

在Meteor论坛中,我读到建议将
Meteor.logootherclients
放在
Accounts.onLogin()中。虽然这是可行的,但有一个问题,那就是当打开多个选项卡(不是浏览器)时,
Accounts.onLogin()
会被多次调用。这是预期产出吗

下面是我的代码:

Accounts.onLogin(() => {
  console.log('onLogin called')
  Meteor.logoutOtherClients((error) => {
    if (error) {
      console.log(`error: ${error.error}`)
    }
  })

  // Some Meteor Method calls here
  alert('Welcome User!')
})
另一个问题是,我在同一
Accounts.onLogin()块中得到了方法调用,并且每次都被调用

meteor@1.4.2.6
accounts-base@1.2.17
问题:
  • 我应该如何防止这种无限调用发生
  • 若我不能阻止这种情况,那个么当用户登录时,我应该在哪里分派方法调用呢?因为很明显,如果我把它放在这个代码块中,它会导致调度被无限地调用,
    alert
    被无限地激发

  • 您还可以看到此处报告的详细信息:

    这是一个已确认的错误。因此,我的解决方法是为用户创建一个手动令牌,而不是使用
    帐户库中的默认令牌。我还手动处理了检查,因此基本上摆脱了Meteor提供的“神奇”服务。

    您的实际问题是什么?你想避免注销同一系统上的其他选项卡吗?嗨@MichelFloyd我刚刚更新了我的问题。这有助于确定我的问题吗?我很难理解为什么会出现无限循环。是否有某个标签被登录然后退出,然后再无限期地登录?@MichelFloyd我自己也不确定,似乎是这样的。我已经在《流星》上报道过了。您可以在那里看到它和复制,包括消除bug的最小设置。