我现在已经尝试了几乎所有的方法,但我的身份验证设置仍然存在问题。我使用Employee作为我的模型,并带有Employee_id和password字段。Blowfish是我的密码哈希器,也是我的控制器/操作中的雇员/索引。
我正试图回应这一点-
$this的输出-
Array ( [Employee] => Array ( [employee_id] => bob [password] => temp ) )
员工模型
<?php
class Employee extends AppModel {
public function beforeSave($options = array()) {
if (isset($this->data[$this->alias]['password'])) {
$this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
}
return true;
}
public $primaryKey = 'employee_id';
public $hasMany = array(
'CustomerInteraction' => array(
'foreignKey' => 'created_by'
),
'Appointment' => array(
'foreignKey' => 'assigned_to'
),
'Customer' => array(
'className' => 'Customer',
'foreignKey' => false
)
);
public $hasOne = array(
'SalesTarget' => array(
'foreignKey' => 'subject'
)
);
public $virtualFields = array(
'full_name' => 'CONCAT(Employee.first_name, " ", Employee.last_name)'
);
}
?>
应用控制器
public $components = array(
'Session',
'Auth' => array(
'flashElement' => 'login_error',
'authError' => 'You must be logged in to view this page.',
'loginError' => 'Invalid Username or Password entered, please try again.',
'loginAction' => array(
'controller' => 'Employees',
'action' => 'index',
),
'authenticate' => array(
'all' => array(
'userModel' => 'Employee',
'passwordHasher' => 'Blowfish'
),
'Form' => array(
'userModel' => 'Employee',
'passwordHasher' => 'Blowfish',
'fields' => array(
'username' => 'employee_id',
'password' => 'password',
)
)
)
),
);
public $uses = array(
'ProgramApplication',
'Employee'
);
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->fields = array(
'username' => 'employee_id',
'password' => 'password'
);
雇员控制员
<?php
class EmployeesController extends AppController {
public $uses = array(
'TimeEntry',
'Employee',
'CakeEmail',
'Network/Email' ,
'CraigslistTemplate',
'Inventory'
);
public $helpers = array(
'DateConversion'
);
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('index','checkUsername','passwordStatus','passwordCheck','convertPassword');
}
public function index() {
//Set layout to loginr
$this->layout = 'login';
//if already logged-in, redirect
if($this->Session->check('Auth.User')){
return $this->redirect(
array('controller' => 'Search', 'action' => 'index'));
}
echo "1";
if($this->request->is('post')) {
echo $this->Auth->login();
if($this->passwordCheck($this->request->data['Employee']['employee_id'],$this->request->data['Employee']['password'])) {
}else{
echo "Invalid username/password";
}
}
指数ctp
<div class="Employees form">
<?php //echo $this->Session->flash('auth'); ?>
<?php echo $this->Form->create('Employee',array('controller' => 'Employees','type' => 'POST')); ?>
<fieldset>
<legend>
<?php echo __('Please enter your username and password'); ?>
</legend>
<?php echo $this->Form->input('employee_id',array('type' => 'Username'));
echo $this->Form->input('password');
?>
</fieldset>
<?php echo $this->Form->end(__('Login')); ?>
</div>
我做了与你相同的设置,并得到了一个与河豚有关的错误。
删除河豚作品('PasswordHasher'=
我还使用了一个虚拟编辑功能来更新用户:
public function edit() {
$data = array(
'employee_id' => '111',
'password' => 'test',
);
$res = $this->Employee->save($data);
}
运行这个功能后,我就可以用
111/test
登录了,没有河豚。
该项目是否需要河豚鱼?你能使用普通密码吗?
我有一个像这样的mysql表 但是我无法用这个函数检索“成人”和“儿童”的值 错误日志显示变量被正确地传递给函数: 为什么此函数返回?
如何获取java主目录? 这样做的时候 一无所获
我的问题是: 接下来我用 它返回[],即不返回任何内容 但是如果我设置cursor=conn.cursor(),同样的查询会返回一些行!怎么了?为什么我不能使用游标?
TestCase 2: baseChars:['a','b'] 所需字符串长度:1 产出: 有人能帮忙吗?我已经把我的代码放在GitHub里了。如果您可以将我的实现更改为非递归,但保留函数返回类型,也将受到重视。
这是我的查看页面代码 我在codeigniter中检查codeigniter表单验证,它复制并粘贴了我的控制器,但出现了相同的错误 这是我的控制器代码 表单验证不返回任何内容和
问题内容: 尽管我发现了与我类似的问题,但我无法独自解决问题。 在我的’../models/user’模型中,我想找到所有用户并将其放入数组,然后将该数组返回给控制器(在这里我将使用信息)。 这是我的代码: 我还注意到,“ console.log(test)”位于“ console.log(docs)”之前。我尝试将’docs’参数作为函数参数传递给’find’,但没有结果。 问题答案: 最好的方