I am using passport js to handle some authentication. However, I am also using angular $route service to handle my templating on the client side. Because of this, I am unsure how to proceed in using passport, as the examples on the doc page assume server side templating. For example,
app.post('/login',
passport.authenticate('local', {
successRedirect: '/',
failureRedirect: '/login',
failureFlash: true
})
);
So based on this, it seems like "/" and "/login" are meant to serve templates, not just the response to a RESTful query or something. The way I am doing things, my templating happens client side. In my angular file that sets everything up
$routeProvider
.when('/', {
templateUrl: 'templates/login.html',
controller: 'MainCtrl'
})
.when('/home', {
templateUrl: 'templates/home.html',
controller: 'MainCtrl'
});
It seems like I am trying to mix and match, and not really understanding either method of doing things.
So I know I have probably worded this horrendously thus far, but what I want to do is something like this
html (login.html)
<h3> Login </h3>
<form action= "login" method="post">
Username:<br>
<input type="text" name="username" value="">
<br>
Password:<br>
<input type="password" name="password" value="">
<br><br>
<input type="submit" value="Submit">
</form>
node backend
i realize I am not authenticating anything, but this much is not yet working for me
passport.use(new LocalStrategy(
function (username, password, done) {
console.log(username); // this does not fire
return done(null, null);
}
));
app.post('/login',
passport.authenticate('local', {
successRedirect: '/home',
failureRedirect: '/',
failureFlash: true
})
);
So I want to authenticate using passport, but use the client side templating/routing to keep the single page application feel.
Can someone please point me in the right direction? Or tell me if what I am doing is completely misguided?
edit : the error I AM getting with my code is
TypeError: undefined is not a function
this is probably not enough to be useful to any of you, but I can go more in depth if needed. The specific error message isn't so much the spirit of what I was trying to ask though.