我是 kohana 3.2 的新手,我找不到任何重新分级身份验证模块的答案。这是我的代码,自从我更改用户模型以扩展 model_auth_user 后,出于某种原因,验证没有正确完成。密码字段可以插入空,如果 password_confirm 和密码字段不同,则不会捕获任何异常:
public function action_new()
{
if ($_POST){
try
{
$user = ORM::factory('user')
->values(array(
'username' => $_POST['username'],
'email' => $_POST['email'],
'password' => $_POST['password'],
'password_confirm' => $_POST['password_confirm']));
$user->save();
$user->add('roles', ORM::factory('role', array('name' => 'login')));
$this->request->redirect('user/index');
}
catch (ORM_Validation_Exception $e)
{
$errors = $e->errors();
}
}
$view = View::factory('user/new')
->bind('errors',$errors); //pass the info to the view
$this->response->body($view); //show the view
}
谢谢