Login facebook in angular-fullstack-generator


#1

I have a problem with angular-fullstack-generator and I don’t know resolve. I have an app online at a specific address: www.example.com, I have also an hybrid app, created with ionic, that runs in local.

The problem is logic. When I click login button in my ionic app, the button opens a location.href to address web $window.location.href = ‘/auth/’ + provider, that in my hybrid app will be file://blabla/auth/blabla and doesn’t work. So I use inappbrowser and I open www.example.com/auth/blabla, the user can do login , but the endpoint /auth/blabla will return a cookie in www.example.com.

In nodejs I have:

export function setTokenCookie(req, res) {
if (!req.user) {
return res.status(404).send(‘It looks like you aren’t logged in, please try again.’);
}
var token = signToken(req.user._id, req.user.role);
res.cookie(‘token’, token);
res.redirect(’/’);
}

The problem is this redirect will go www.example.com, how can I handle it ? In Ionic I don’t have a server web, and I would not change login method because the app site is online.
Help me, please.