Devise / Rails - 如何只允许管理员为他人创建帐户? [英] Devise/Rails - How to allow only admin to create account for others?

查看:131
本文介绍了Devise / Rails - 如何只允许管理员为他人创建帐户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用devise作为我的认证解决方案,现在我正在考虑授权。在我的项目中,我(管理员)是唯一被授权为其他人创建帐户的人。



我想知道是否有办法可以做到这一点,而不用太多的黑客。事实上,如果Devise已经登录,Devise不允许用户访问注册页面。



感谢您的建议!

解决方案

您可以尝试 rails_admin 宝石与Devise一起处理任何管理员特定的任务。您需要添加更多代码进行设置,但至少您可以避免在改变与Devise的交互方面对该解决方案进行黑客攻击。


I am using devise as my authentication solution and now i am thinking about authorization. In my project I (the admin) is the only person authorized to create account for others.

I wonder if there is a way to do it without to much hack. In fact, Devise doesn't allow user to access to the signup page if he is already logged in.

Thanks for your advice on it!

解决方案

You can try the rails_admin gem in conjunction with Devise to handle any admin-specific tasks. You'll need to add more code to set it up, but at least you avoid hacking around the solution in terms of changing your interactions with Devise.

这篇关于Devise / Rails - 如何只允许管理员为他人创建帐户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆