Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't use with koa-better-body #144

Open
wubocong opened this issue Oct 18, 2016 · 3 comments
Open

can't use with koa-better-body #144

wubocong opened this issue Oct 18, 2016 · 3 comments

Comments

@wubocong
Copy link

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?

@maotora
Copy link

maotora commented Jan 9, 2017

@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
Copy link

maotora commented Jan 9, 2017

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

@wubocong
Copy link
Author

wubocong commented Jan 9, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants