authentication - CakePHP - 两种类型的用户进行身份验证

标签 authentication cakephp

我想在同一个应用程序中有两个不同的注册/登录。一种用于公司,一种用于员工,因为注册公司所需的信息与注册员工不同。

是否可以使用auth组件实现两种不同的注册/登录?

最佳答案

您可以动态更改 AuthComponent 的 configurationbeforeFilter() 。例如:

function beforeFilter() {
    if (/* company login required */) {
        $this->Auth->userModel = 'Company';
        // or:
        $this->Auth->userScope = array('User.type' => 'company');
    }
}

关于authentication - CakePHP - 两种类型的用户进行身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1557816/

相关文章:

php - CakePHP-如何在CakePHP项目中使用套接字连接到Docker的数据库容器

javascript - SSL & JQuery = 没有挂锁/为什么?

raphael - Processing.js vs. CAKE vs. Raphael.js

cakephp - 调用$ this-> model-> create()在cakephp中的 Controller 中崩溃

php - Cakephp 系统用于更新给定 id 的行,如果 id 不存在,则创建一个新行

php - 从 ssl 移动到非 ssl 时 session 不保存

javascript - 如何通过了解身份验证状态访问 protected 路由/禁用 Auth Guard

zend-framework - 如何使 Zend_Auth 对用户名大小写不敏感?

c# - 对 Flickr API 的签名请求签名无效(在控制台中模拟)

authentication - FB 错误 :Expected 1 '.' in the input between the postcard and the payload