gpt4 book ai didi

mysql - CodeIgniter 用户访问

转载 作者:行者123 更新时间:2023-11-29 11:01:17 25 4
gpt4 key购买 nike

我需要帮助,我给每个页面赋予值 1,所以如果其他用户无法访问没有值 1 的页面,我想要什么

我的逻辑是这样的:

<li class="treeview">
<a href="#">
<i class="fa fa-gears"></i> <span>User Setting</span> <i class="fa fa-angle-left pull-right"></i>
</a>
<ul class="treeview-menu">
<li><a href="<?= $this->config->base_url() ?>changepassword?f=1"><i class="fa fa-circle-o"></i> Change Password</a></li>
<li><a href="<?= $this->config->base_url() ?>infouser"><i class="fa fa-circle-o"></i> Info User</a></li>
</ul>
</li>

如果没有访问权限的用户B想要打开页面changepassword.php,请禁用,因为在数据库访问中他们的值不是1而是0。

但是他们可以打开页面 infouser.php 因为值不是 1

任何人都可以使用 codeigniter 给我逻辑,我的数据库如下所示:

no | UID     | PWD               |  access |
1 | user A | user A | 11 |
2 | user B | user B | 10 |

最佳答案

那么,您需要创建 ACL 功能。

您需要在其中创建一个数据透视表。

id (int) 11
user_id (int) 11
controller (text)
action (text)

数据库记录可以是:

| 1 | 3 | users | dashboard |
| 1 | 3 | users | profile |
| 1 | 3 | users | password |

您可以创建一个界面来更新用户及其允许的 Controller /操作

通过这种方式,您可以允许用户访问他们各自的操作。

要获取权限,您需要使用当前用户 ID 运行查询,并从 URL 或 getRoutes 函数获取 Controller /操作。

关于mysql - CodeIgniter 用户访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42196647/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com