pouchbase icon indicating copy to clipboard operation
pouchbase copied to clipboard

/logout does not work

Open jzkunlun opened this issue 11 years ago • 4 comments

call /logout, it return 'bad request 400'
Error: invalid json at parse (/home/dir/pouch.host/node_modules/body-parser/lib/types/json.js:72:15) at /home/dir/pouch.host/node_modules/body-parser/lib/read.js:98:18 at IncomingMessage.onEnd (/home/dir/pouch.host/node_modules/body-parser/node_modules/raw-body/index.js:136:7) at IncomingMessage.g (events.js:175:14) at IncomingMessage.EventEmitter.emit (events.js:92:17) at _stream_readable.js:920:16

jzkunlun avatar Dec 21 '14 17:12 jzkunlun

Yup, the issue is browser-request is sending Accept: application/json when the POST request has no body, express json parser is trying to parse the request as json but fails with no body and crashes

We can not use .defaults({json: true}) and only add that to requests that have a body, or patch browser-request or express json body parser, I hadnt dont it yet since I was possibly thinking of replacing browser-request with the ajax library from pouchdb, but that part isnt ready yet

daleharvey avatar Dec 21 '14 18:12 daleharvey

Thank you for your reply. I got easier solution to work around it. Just use opts hash as we did on login, opts.data = {}; that's it. /logout work very well.

I have another questions for you. If you have time, please shed some light on.

  1. How does this work for Mobile Cordova app? Email verification cannot go to Cordova app.
  2. When email verification launches different browser than app browser, how could app browser get authentication?

Jing

On Sun, Dec 21, 2014 at 1:16 PM, Dale Harvey [email protected] wrote:

Yup, the issue is browser-request is sending Accept: application/json when the POST request has no body, express json parser is trying to parse the request as json but fails with no body and crashes

We can not use .defaults({json: true}) and only add that to requests that have a body, or patch browser-request or express json body parser, I hadnt dont it yet since I was possibly thinking of replacing browser-request with the ajax library from pouchdb, but that part isnt ready yet

— Reply to this email directly or view it on GitHub https://github.com/pouchdb/pouch.host/issues/45#issuecomment-67778966.

jzkunlun avatar Dec 21 '14 18:12 jzkunlun

I havent solved those problems yet, it seems like it should be possible to have the email launch the installed application but I havent looked into it

daleharvey avatar Dec 21 '14 19:12 daleharvey

I believe you can use a custom protocol handler in a separate link in the email to load in an app.

Something like: my-pouch-app://{in-app-registration-url}/{token}

The app (afaik) gets that entire string, and can do what it wants with it.

I've not personally done this, so your mileage may vary. :blue_car:

BigBlueHat avatar Apr 06 '15 14:04 BigBlueHat