TinyAuth for CakePHP 3 登录插件

Login plugin of TinyAuth for CakePHP 3

我的用户登录有问题,每个用户都有不同的表,因为他们有不同的属性(学生、管理员、教授),我不知道如何为多个用户配置 TinyAuth用户模型。对不起我的英语不好。谢谢

为了让您的生活更轻松,您应该将它们都放在相同的 users table 下,但也要有一个 groups table。 groups table 将有 studentsprofessorsadministratorsusers table 将有一个 group_id 列,每个用户可以在其中引用 groups table。

|users|
-> id
-> group_ip
-> username
-> first_name
-> last_name
-> created
-> updated

|groups|
-> id
-> name
-> created
-> updated

使用此技术需要您进行正确的关系设置。

如果您不喜欢使用 groups,您可以在 users table 中添加一个 role 字段。

|users|
-> id
-> role
-> username
-> first_name
-> last_name
-> created
-> updated

无论您做出何种选择,您都不应该创建多个 table 并期望统一登录能够很好地工作。

您应该遵循 CakePHP 的博客教程,以更好地了解如何使用 role 技术。

http://book.cakephp.org/3.0/en/tutorials-and-examples/blog-auth-example/auth.html