显示设备编辑密码屏幕
在我使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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.