passport-local
passport-local copied to clipboard
can't use with koa-better-body
options = options || {};
var username = lookup(req.body, this._usernameField) || lookup(req.query, this._usernameField);
var password = lookup(req.body, this._passwordField) || lookup(req.query, this._passwordField);
if (!username || !password) {
return this.fail({ message: options.badRequestMessage || 'Missing credentials' }, 400);
}
I saw this in lib/strategy.js:70. It only allows to get params from req.body or req.query, but koa-better-body default use req.fields as post's body field. Consider adding customization to this?
@wubocong did you find the solution to this?
I've been facing the same problem getting Bad Request
for quite a long time and can't really move forward.
Thank you.
@wubocong ooh i just solved it with this issue on koa-better-body.
Basically passed,
app.use(convert(body({
multipart: true,
fields: 'body'
})));
to change koa-better-body
's fields to body well known to passport-local
.
Hate it that i now have to change all my parsings to face body
.
I know this but it is not what I want. I need to use fields
in my code as name. I accomplished this by modifying the source code. This is really bad.