成功登录Google后加载页面

时间:2015-01-20 08:28:18

标签: javascript authentication meteor google-api

通过Google API按钮成功登录后,如何加载新页面?

这就是我的javascript的样子(由Google提供):

function signinCallback(authResult) {
if (authResult['status']['signed_in']) {
// Update the app to reflect a signed in user
// Hide the sign-in button now that the user is authorized, for example:
window.location.href='main.html'
document.getElementById('signinButton').setAttribute('style', 'display: none');
} else {
// Update the app to reflect a signed out user
// Possible error values:
//   "user_signed_out" - User is signed-out
//   "access_denied" - User denied access to your app
//   "immediate_failed" - Could not automatically log in the user
console.log('Sign-in state: ' + authResult['error']);
}
}

我应该填写什么来将应用更新到我的主页main.html?

1 个答案:

答案 0 :(得分:1)

如果您使用iron:router,则可以尝试此操作。

function signinCallback(authResult) {
Router.go('/') //or whatever path you want to go
document.getElementById('signinButton').setAttribute('style', 'display: none');
}

如果你没有铁:路由器只需添加他Meteor add iron:router

首先配置路径

Router.route('/', {name: 'mainPage'});
相关问题