显示设备编辑密码屏幕

发布于 2024-11-29 10:16:18 字数 455 浏览 0 评论 0原文

在我使用 devise 的 Rails 3 应用程序中,我想为用户提供一个编辑密码的链接。

我有一个标准链接指向: /users/password/edit ... 下面的日志输出

Started GET "/users/password/edit" for 127.0.0.1 at 2011-08-10 10:11:46 -0700
  Processing by Devise::PasswordsController#edit as HTML
  User Load (0.6ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 3 LIMIT 1
Redirected to http://localhost:3000/
Completed 302 Found in 309ms

为什么 Rails 会重定向?为什么我无法显示修改密码页面?谢谢

In my rails 3 app using devise, I want to provide a link for users to edit their password.

I have a standard link that points to: /users/password/edit ... Log output below

Started GET "/users/password/edit" for 127.0.0.1 at 2011-08-10 10:11:46 -0700
  Processing by Devise::PasswordsController#edit as HTML
  User Load (0.6ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 3 LIMIT 1
Redirected to http://localhost:3000/
Completed 302 Found in 309ms

Why is rails redirecting? Why can't I show the edit password page? Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执手闯天涯 2024-12-06 10:16:18

Devise::PasswordsController#edit 适用于希望使用重置令牌更改密码的未经身份验证的用户。此重置令牌之前已通过电子邮件发送给用户(重置密码说明)。如果用户已经登录,则此编辑密码页面将始终重定向到登录后路径,因为经过身份验证的用户不应访问它。

我想您想要的是允许用户登录后更改密码。为此,您必须使用 Devise::RegistrationsController#edit

Devise::PasswordsController#edit is for non-authenticated users who wish to change their password using a reset token. This reset token was previously sent to the user in an email (Reset password instructions). If the user is already logged in, this edit password page will always redirect to the after-sign-in path since it shouldn't be accessible to authenticated users.

I suppose what you want is to allow the user to change his password after logging in. You have to use Devise::RegistrationsController#edit for that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文