I'm trying to pass login information from a form via angular to a back-end express endpoint. The passport middleware that is doing the authentication fails every time and goes to the failure redirect. The trouble is that I can't find via documentation what POST parameters it's expecting, or what it's doing with them. Is this a failure of the strategy I'm using (a plugin via userapp.io) or is the actual username/password wrong?
The login endpoint looks like this:
router.post('/login', passport.authenticate('userapp', {
failureRedirect: '#/login',
failureFlash: 'Invalid username or password',
successFlash: 'Welcome!' }),
function (req, res) {
res.cookie(SESSION_TOKEN, req.user.token);
res.redirect('/');
});
(Note that this is eventually connected to /auth/login
, which matches the post action below)
The form that submits to that endpoint looks like this:
<form method='post' action='/auth/login'>
<input name="login" placeholder="Username"><br>
<input name="password" placeholder="Password" type="password"><br>
<p><button type="submit">Log in</button></p>
<p ng-show="loading"><img src="https://app.userapp.io/img/ajax-loader-transparent.gif"></p>
<p ng-show="error">{{ error.message }}</p>
</form>
Is this submitting the data to the endpoint correctly, and how can I go about further debugging what's happening? Observed behavior right now is simply that login fails and the user ends up at the failureRedirect.
Another option I'm aware of is to use the ua-login
directive shown in this example instead of my own form. The trouble there is that there seems to be some undocumented configuration magic; using the ua-login
directive results in attempts for the client to post to a non-existant URL. Existing tutorials don't seem to indicate what configuration is necessary to make ua-login
work.