CakePHP - authentication component, using a different table name and column name

前端 未结 2 408
暖寄归人
暖寄归人 2021-01-17 01:42

Just for organization sake, I wanted to use a different table for the authentication component to check, but it doesn\'t quite work. While I can initially state:

2条回答
  •  忘掉有多难
    2021-01-17 02:08

    First, model names are generally singular. Are you sure you didn't mean CoreUser which would look in the core_users table?

    Secondly, you can use the email field instead of username by setting the fields key on your auth setup.

    public $components = array(
        'Auth' => array(
            'authenticate' => array(
                'Form' => array(
                    'userModel' => 'CoreUser',
                    'fields' => array('username' => 'email')
                )
            )
        )
    );
    

    See the book for more information.

提交回复
热议问题