The next parameter in the CouchDB Session API?

In Couchapp, I would like to have a login form that works without Javascript.

The session API wiki page states that after reassigning or failing authentication, the following _session parameter can be specified.

That sounds great, and I would like to redirect to the show function, which then can check the user credentials and display something accordingly.

I tried using the form:

 <form action="/_session" method="POST"> <input type="text" name="name"> <input type="password" name="password"> <input type="hidden" name="next" value="/somewhere"> <input type="submit"> </form> 

and also using curl :

 curl -X POST http://localhost:5984/_session -d 'name=foo&password=bar&next=/somewhere' 

but to no avail: I continue to receive code 200 (OK) if my credentials are correct and code 401 (unauthorized) if they are not, but I never get the expected 302 (redirect).

Is this feature unavailable (I'm using Couchdb 1.1), or am I doing it wrong?

If this feature no longer exists, do you have an alternative?

+4
source share
1 answer

After looking at the source code, it looks like the function was implemented in version 1.1.0.

In the CouchDB source code, see the following implementation of parmeter .

The parameter is supported only as a query string, and not as a representation of a form field. That way, if you POST before /_session?next=/somewhere with the form data in the POST body, it will work.

 curl -i https://example.iriscouch.com/_session?next=/stuff -d 'name=me&password=secret' HTTP/1.1 302 Moved Temporarily Set-Cookie: AuthSession=[cookie value]; Version=1; Path=/; HttpOnly Server: CouchDB/1.1.0 (Erlang OTP/R14B03) Location: http://example.iriscouch.com/stuff Date: Tue, 19 Jul 2011 01:07:52 GMT Content-Type: text/plain;charset=utf-8 Content-Length: 52 Cache-Control: must-revalidate {"ok":true,"name":"me","roles":["whoever"]} 
+2
source

All Articles