Kohana的 - 用户注册运行时错误(AUTH)
-
13-09-2019 - |
题
我实施中的Kohana在auth模块,我似乎不能弄清楚该错误消息的源 - 它发生时我认为在数据库中创建一个用户(它确实成功登记表)。
检测到一个错误,其阻止了这种页面的加载。如果问题仍然存在,请与网站管理员联系。
应用/控制器/ register.php [83]:
未定义的属性:Register_Controller :: $ AUTH
我使用jQuery验证表单,和之前我加入jQuery的形式完美工作,所以这个问题可能与Ajax请求的事,但我不知道从哪里里去......
下面是堆栈跟踪:
*
Register_Controller->create_user( )
* system/core/Kohana.php [291]:
ReflectionMethod->invokeArgs( Register_Controller Object
(
[template] => View Object
(
[kohana_filename:protected] => /var/www/ko/testsite/system/views/form/template.php
[kohana_filetype:protected] => .php
[kohana_local_data:protected] => Array
(
)
)
[auto_render] => 1
[uri] => URI Object
(
)
[input] => Input Object
(
[use_xss_clean:protected] => 1
[magic_quotes_gpc:protected] => 1
[ip_address] =>
)
)
)
*
Kohana::instance( )
* system/core/Event.php [209]:
call_user_func( Array
(
[0] => Kohana
[1] => instance
)
)
* system/core/Bootstrap.php [55]:
Event::run( system.execute )
* index.php [106]:
require( system/core/Bootstrap.php )
和这里的在Register_Controller的create_user()方法:
public function create_user()
{
if($_POST)
{
$post = $this->input->post();
$user = ORM::factory('user');
$user->add(ORM::factory('role', 'login'));
if($user->validate($post, TRUE))
{
$this->auth->login($user, $post->password);
url::redirect();
}
else
{
url::redirect('register');
}
}
}
任何人有什么建议? :P
解决方案
你得到的错误是因为变量$这个 - >权威性不会在你的控制器存在
我猜你的意思做的 $this->auth = Auth::instance();
在构造函数中。
不隶属于 StackOverflow