[英]PHP Code Igniter Ion Auth - Can't successfully create a new tier of user
I'm rather new at CodeIgniter and especially Ion Auth. 我是CodeIgniter的新手,尤其是Ion Auth。 I'm building a website which will have three tiers of user: User, Moderator and Admin.
我正在建立一个拥有三层用户的网站:用户,主持人和管理员。 My aim is to use this code snippet:
我的目的是使用以下代码片段:
if (!$this->ion_auth->in_group('moderator'))
{
//redirect them to the because they must be a moderator
redirect($this->config->item('base_url'), 'refresh');
}
to check if user is an administrator before granting access. 在授予访问权限之前检查用户是否是管理员。
I have already edited my 'groups' table as follows: 我已经按如下方式编辑了“组”表:
(ID, name, description) 1 admin Administrator, 2 members General User, 3 moderator Moderators (ID,名称,说明)1位管理员管理员,2位成员普通用户,3位主持人主持人
I have also updated one user in my 'user_groups' table to have 'group_id' of '3'. 我还已将“ user_groups”表中的一个用户更新为“ group_id”为“ 3”。
However, when I test my code, it will always allow my admin to see the page (which is fine) but it will redirect my moderator. 但是,当我测试我的代码时,它将始终允许我的管理员查看页面(很好),但它将重定向我的主持人。
I haven't changed anything in my ion_auth library file, or any models, but I did manually create and insert into all my tables as MySql didn't like it being loaded. 我没有更改ion_auth库文件或任何模型中的任何内容,但是由于MySql不喜欢加载它,因此我确实手动创建并插入了所有表。
EDIT: I think it may be connected to my Databases, as I've tried to promote a user to an admin by changing their 'group_id' in the 'users_group' table and my website won't recognize them as an admin. 编辑:我认为它可能已连接到我的数据库,因为我试图通过更改“ users_group”表中的“ group_id”将用户提升为管理员,而我的网站无法将其识别为管理员。 However, I am not receiving any errors, but my code is just not recognizing anyone but the admin.
但是,我没有收到任何错误,但是我的代码仅能识别除管理员以外的任何人。
Thank you in advance for any help you can give - I'm pulling my hair out!!! 在此先感谢您提供的任何帮助-我正在拔头发!!!
I am working with this ION Auth too and works perfectly fine for me. 我也正在使用此ION Auth,并且对我来说效果很好。 I created also multi- access user.
我还创建了多访问用户。 What I did is I modified only the controller.
我所做的是仅修改了控制器。 Models and libraries i did'nt touch it.
我没有碰过模型和库。
Can you more elaborate your questions? 您能否进一步阐述您的问题? What do you mean it redirect your moderator (redirect to where).
您是什么意思,它将您的主持人重定向(重定向到何处)。
Give a detailed question. 提出一个详细的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.