简体   繁体   English

CakePHP中的身份验证

[英]Authentication in CakePHP

how can i use myown login function to authenticate users in cakePHP 我如何使用myown登录功能对cakePHP中的用户进行身份验证
because my users table structure is different from the cakePHP structure. 因为我的用户表结构不同于cakePHP结构。

even i overridden the login function it still executing the login function in parent class 即使我重写了登录功能,它仍然在父类中执行登录功能

When using models that don't reflect CakePHP's conventions, there are a few things you can configure to get things working. 当使用不反映CakePHP约定的模型时,可以配置一些东西来使它们起作用。

When you create your User model (or whatever you have called it), you can specify which database the table is in, what the name of the table is, if the table has a prefix , what the primary key field is called (usually id ), and what the display field is (usually name or title ). 创建用户模型(或任何您称呼的模型)时,可以指定表所在的数据库 ,表的名称 ,如果表具有前缀则称为主键字段 (通常为id ),以及显示字段是什么(通常是nametitle )。

When setting up AuthComponent , you can also specify what model to use (usually User ) and what the username and password fields are called. 设置AuthComponent ,您还可以指定要使用的模型 (通常为User )以及调用的用户名和密码字段

A combination of the above configuration options should usually be enough to get CakePHP understanding how to your table schema is set up. 上面配置选项的组合通常应该足以使CakePHP了解如何设置表架构。

However, in some cases this isn't enough, so you can override or extends parts of the core AuthComponent to get it working the way you want (usually just the identify method is needed, as you pointed out). 然而,在某些情况下,这是不够的,所以您可以覆盖或扩展核心的部分AuthComponent得到它的工作您想要的方式(通常只是identify需要的方法,正如你所指出)。 A few example scenarios would be LDAP authentication , trying to authenticate over multiple User tables , and trying to authenticate where there are joined User and Email tables . LDAP身份验证是一些示例方案,它尝试对多个User表进行身份验证,并尝试对结合了User和Email表的位置进行身份验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM