如何扩展kohana用户身份验证模块 [英] how to extend kohana user auth module
问题描述
所以我正在使用kohana用户模块,我想扩展我的注册页面,现在它添加了用户名,电子邮件和密码,但是我想添加一些额外的字段,而我只是找不到在哪里可以我做到了.
So i'm using kohana user module, and i would like to extend my register page, now it adds username, email, and password but i would like to add some extra fields, and i just can't find where can i do it.
我发现了导致Auth::instance()->register($_POST, true);
的function action_register
,所以我发现了导致$user = ORM::factory('user');
和$user->create_user($fields, array()
的这个function register($fields)
,所以我被困在这里,我什至不确定我是否要去正确的道路...
I found function action_register
which leads to Auth::instance()->register($_POST, true);
so i found this function register($fields)
which leads to $user = ORM::factory('user');
and $user->create_user($fields, array()
so i'm stuck somewhere here, i'm not even sure if i'm going the right path...
推荐答案
只需在 application/classes/model 文件夹下创建 user.php 文件,并将其放入: /p>
Just create user.php file under application/classes/model folder and put this inside:
<?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行):
After checking the register function, here is the place for other fields (line 22-27):
$user->create_user($fields, array(
'username',
'password',
'email',
'user_type',
'other field',
'other field2',
));
当然,您的表中必须存在other_field
和other_field2
.
Of course you'll need to have other_field
and other_field2
exist in your table.
这篇关于如何扩展kohana用户身份验证模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!