gpt4 book ai didi

forms - CouchDB Session API 中的下一个参数?

转载 作者:行者123 更新时间:2023-12-01 04:09:58 24 4
gpt4 key购买 nike

在 Couchapp 中,我想要一个无需 Javascript 即可工作的登录表单。

wiki page about the Session API声明可以向 _session 提供下一个参数在认证成功或失败后重定向。

这听起来很棒,我想重定向到一个显示功能,然后可以检查用户的凭据并相应地显示一些内容。

我尝试使用一种形式:

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

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

但没有成功:如果我的凭据正确,我会继续收到代码 200(OK),如果不正确,我会收到代码 401(未经授权),但我从来没有得到我期望的 302(重定向)。

这个功能消失了吗(我使用的是 Couchdb 1.1)还是我做错了?

如果此功能不再存在,您有替代方案吗?

最佳答案

浏览源代码后,该功能似乎是在 v1.1.0 中实现的。

next parmeter implementation在 CouchDB 源代码中。

该参数仅支持作为查询字符串,而不支持作为表单字段提交。因此,如果您 POST/_session?next=/somewhere使用 POST 正文中的表单数据,它将起作用。

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"]}

关于forms - CouchDB Session API 中的下一个参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6738766/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com