passport-local icon indicating copy to clipboard operation
passport-local copied to clipboard

can't use with koa-better-body

Open wubocong opened this issue 8 years ago • 3 comments

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 avatar Oct 18 '16 10:10 wubocong

@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.

maotora avatar Jan 09 '17 10:01 maotora

@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.

maotora avatar Jan 09 '17 10:01 maotora

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.

wubocong avatar Jan 09 '17 17:01 wubocong