如何扩展kohana用户认证模块


how to extend kohana user auth module

所以我使用kohana用户模块,我想扩展我的注册页面,现在它添加了用户名,电子邮件和密码,但我想添加一些额外的字段,我只是找不到我在哪里可以做到。

我发现function action_register导致Auth::instance()->register($_POST, true);,所以我发现这个function register($fields)导致$user = ORM::factory('user');$user->create_user($fields, array(),所以我被困在这里的某个地方,我甚至不确定我是否走正确的道路…

application/classes/model文件夹下创建user.php文件,并将其放入

<?php
defined('SYSPATH') or die('No direct access allowed.');
class Model_User extends Model_Auth_User
{
   public function create_user($values, $expected)
   {
      // Your definition of the function
   }
}

检查寄存器函数后,这里是其他字段的位置(第22-27行):

$user->create_user($fields, array(
                                'username',
                                'password',
                                'email',
                                'user_type',
                                'other field',
                                'other field2',
                        ));

当然你需要有other_fieldother_field2在你的表