views:

496

answers:

1

I'm implementing the auth module in Kohana, and I can't seem to figure out the source of this error message--it happens when I submit a registration form that creates a user in the database (which it successfully does).

An error was detected which prevented the loading of this page. If this problem persists, please contact the website administrator.

application/controllers/register.php [83]:

Undefined property: Register_Controller::$auth

I'm using jquery to validate the form, and the form worked perfectly before I added the jquery, so the problem might have to do with the ajax requests, but I'm not sure where to go from there...

Here's the stack trace:

   *

     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 )

And here's the create_user() method in the Register_Controller:

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');
      }
   }
}

Anyone have any suggestions? :P

+1  A: 

The error you're getting is because the variable $this->auth doesn't exist in your controller

I'm guessing you meant to do $this->auth = Auth::instance(); in the constructor.

Matt
thanks so much--for some reason, I thought I had already included that
mportiz08