cakephp - cakephp $this- auth- identify() 返回 false
问题描述
请我真的需要帮助我在论坛上尝试了几乎所有东西
方法 $this->Auth->identify(); 总是返回假
数据库中密码的长度是 varchar(255)
我的 cakephp 版本是 3.6.8
候选控制器
public function login()
{
if ($this->request->is('post'))
{
$candidat = $this->Auth->identify();
if ($candidat)
{
$this->Auth->setUser($candidat);
return $this->redirect(['Controller'=>'Candidat','action'=>'index']);
}
$this->Flash->error(__('The candidat could not be saved Please try again.'));
}
}
应用控制器
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler', [
'enableBeforeRedirect' => false,
]);
$this->loadComponent('Flash');
$this->loadComponent('Auth', [
'authError' => 'Vous croyez vraiment que vous pouvez faire cela?',
'authenticate' => [
'Form' => [
'fields' => ['username' => 'email','password' => 'password']
]
],
'loginAction' => [
'controller' => 'candidat',
'action' => 'login',
],
'storage' => 'Session'
]);
}
登录
<?= $this->Form->create() ?>
<fieldset>
<legend><?= __('login') ?></legend>
<?php
echo $this->Form->control('Email_cand',['label'=>'Email']);
echo $this->Form->control('password',['label'=>'mot de passe']);
?>
</fieldset>
<?= $this->Form->button(__('connecter')) ?>
<?= $this->Form->end() ?>
解决方案
推荐阅读
- c++ - CMake 不会先构建添加的子目录
- c# - 使用asp.core html标签生成带有Route属性的Action链接
- java - 使用 websphere liberty 应用程序从经典 websphere 应用程序访问远程 ejb
- asp.net-core - 如何将 DisplayNameFor 与类常量一起使用?
- node.js - 找不到路由 404 问题
- spring-boot - ElasticSearch 1.7(Spring Data ElasticSearch)通过查询更新需要大量时间来更新文档
- kotlin - PeriodicWorkRequest 不重复
- python - PySpark where 子句条件条件
- c# - 在 IIS 上的已发布应用程序中,每次我重新启动服务器或更改应用程序配置中的某些内容时,都会卸载项目引用
- java - 需要澄清 Oracle 教程解释何时使用迭代器与 for-each 构造