2017-09-15 91 views
0

我使用Google recaptcha来授权用户不是机器人,这部分工作! :)Accounts.validateLoginAttempt破坏用户在刷新后保持登录

我用

Accounts.validateLoginAttempt((data) => { 
if (someThingThatWillValidateTrueIfUserIsLoggedIn) { 
    return true // Will not run google Captcha security messure.. 
} 

} 

,使我的职务要求序Google验证公众。我想我的问题是我应该用什么来从validateLoginAttempt返回真正的imediatly。如果我删除validateLoginAttempt,用户将在刷新后保持登录状态。

我尝试使用

Accounts.user() // Undef 

Meteor.user() // Undef 

this.connection // Undef 

this.userId // Undef 

,但没有运气...我如何使用validateLoginAttempt和保持用户的能力保持登录浏览器后刷新?

回答

0

好了,这花了一段时间才能找出:(,但事实是,在一个帐户参数包含恢复数据,以及这样做

Accounts.validateLoginAttempt((data) => { 
    if (data.type === 'resume' && data.allowed) { 
     return true; 
    } 
    ... code for doing captcha check.. 
} 

效果很好!! :)