This is a very basic question that, for whatever reason, I cannot figure out why this will not work.
I have iron router installed and a template called “chat”.
Template.login.events({
'click a.facebookLogin' : function(event){
event.preventDefault();
Meteor.loginWithFacebook({
requestPermissions: ['email', 'public_profile', 'user_friends']
}, function(error){
if (error)
console.log(error);
else
Router.go('/chat');
});
}
});
I get redirected to the Facebook login page and can login and collect data. However,I am not redirected to my chat template after I login.
I can visit localhost/3000/chat and my template is present there. I essentially copied the exact formatting from the documentation.
Sorry for such an easy question – but I am at a loss.
Thanks!
As per the docs here (http://docs.meteor.com/#/full/meteor_loginwithexternalservice) -
Called with no arguments on success, or with a single Error argument on failure. The callback cannot be called if you are using the “redirect” loginStyle, because the app will have reloaded in the meantime; try using client-side login hooks instead.
So, using this callback is the way to go - http://docs.meteor.com/#/full/accounts_onlogin
This works for me - I am setting the redirectUrl in the client side call.
ServiceConfiguration.configurations.upsert({
service: 'facebook'
}, {
$set: {
appId: '***************',
secret: '************************************',
loginStyle: 'redirect'
}
});
Template.signUp.events({
'click [data-action=login]' (e, tmpl) {
e.preventDefault();
Meteor.loginWithFacebook({
requestPermissions: ['email', 'public_profile', 'user_friends'],
redirectUrl: "/"
});
},
});