如何在其他控制器登录视图中使用restful_authentication?

发布于 2024-07-16 04:00:35 字数 289 浏览 6 评论 0原文

我安装了restful_authentication及其工作原理,登录页面允许我登录,但我有另一个名为admin的控制器,并且想要在管理控制器中嵌入登录视图。 实际上登录视图的 url 是: localhost:3000/login (它有效,我需要这样用户才能登录)。 我需要: localhost:3000/admin/login (包含管理视图及其供管理员和员工登录)。 我希望管理/登录视图 form_for 调用 :controller => Restful_authentication,:动作=> 认证。 怎么做? TIA。

i installed restful_authentication and its working, the login page allows me to login but i have another controller called admin and want to embed a login view inside the admin controller. Actually the url to the login view is : localhost:3000/login (it worked and i needed so that users can log in). I need : localhost:3000/admin/login (that contains admin views and its for admin and staff to log in). I want the admin/login view form_for to call :controller => restful_authentication, :action => authenticate. How to do that? TIA.

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

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

发布评论

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

评论(1

嗳卜坏 2024-07-23 04:00:35

您最好的选择可能是使用 Restful_authentication 提供的默认登录控制器并将其保留在原处。 这将使您将来可以更轻松地升级该插件。 然后,如果您想要一个单独的登录表单,请将登录表单分解为一部分以供重用,或者实现您自己的表单,但将其指向默认表单使用的同一控制器。 最后,为了在某些控制器/操作上实现管理要求,这里有一个很好的解决方案:

http: //refactormycode.com/codes/20-restful_authentication-role-requirements

Your best bet is probably to use the default login controller restful_authentication provides and leave it where it is. This will allow you to more easily upgrade that plugin in the future. Then, if you want a separate login form either break the login form out into a partial for reuse or implement your own but point it to the same controller used by the default form. Finally, for implementing administrative requirements on certain controllers/actions, here is a good solution:

http://refactormycode.com/codes/20-restful_authentication-role-requirements

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