我在Kohana Auth模块中遇到两个问题:
到目前为止我做了什么:
希望任何人都可以帮助我......真的是一个关键的要求..
我的一些参考资料:
答案 0 :(得分:0)
也许这会有所帮助: 注册行动:
$extra_rules = Validation::factory($this->request->post())
->rule('password', 'not_empty')
->rule('password', 'min_length', array(':value', '8'))
->rule('password_confirm', 'matches', array(':validation', 'password_confirm', 'password'))
$user->create($extra_rules);
//if You want to enable login add a role, or You can put it later on account confirmation or something
if ($user->saved()) {
$user->add('roles', 1);
}
登录操作:
$logged = Auth::instance()->login($this->request->post('username'), $this->request->post('password'), $_POST['autologin'] = true);
if ($logged == true) {
$user = Auth::instance()->get_user();
$userId = $user->id;
HTTP::redirect('somewhere');
} else {
$validation = Validation::factory($this->request->post())
->rule('username', 'not_empty')
->rule('password', 'not_empty');
if ($validation->check()) {
$validation->error('username', 'general');
}