javascript - ExpressJS and Angular - 'leaving' the app to do server-side authentication -
my app runs on nodejs, expressjs , angularjs. i'm trying facebook authentication using passportjs. avoid posting bunch of unnecessary code, let's passport code works intended , logs facebook, grabs token , receives response.
in expressjs routes set follows:
app.get('/', routes.index); app.get('/fbauth', passport.authenticate('facebook', { scope: 'email' })); app.get('/fbauthed', passport.authenticate('facebook',{ failureredirect: '/' }), routes.loggedin); app.get('/logout', function(req, res) { req.logout(); res.redirect('/'); });
my server set @ localhost:3000
.
question
my issue angular not behaving @ all. when put link on page goes href="/fbauth"
(this goes localhost:3000/fbauth
) see address bar change localhost:3000/fbauth
split second, main localhost:3000
page reloads.
however, if type localhost:3000/fbauth
address bar, authentication happens , i'm passed along facebook -> localhost:3000/fbauthed
.
i think happening because angular routes trying 'take over' url in <a>
link, have no idea how achieve it. i've tried configuring angular routes to:
when('/fbauth', { redirectto: '/fbauth' }).
but loads blank screen. how can make 2 work together?
adding target="_self" works in angular 1.0.1:
sign in facebook
this feature documented (http://docs.angularjs.org/guide/dev_guide.services.$location - search '_self')
if you're curious, @ angular source (line 5365 @ v1.0.1). click hijacking happens if !elm.attr('target') true.
Comments
Post a Comment