1
votes

I started using Kohana 3.3 for my application project. I created a basic Account controller with actions (login/logout) that works perfectly using the ORM Auth method, without using any custom models.

public function action_login()
{
    if (Auth::instance()->logged_in())
    {
        $this->redirect('profile');
    }

    $this->template->content = View::factory('account/login')
        ->bind('message', $message)
        ->bind('errors', $errors);

    if (HTTP_Request::POST == $this->request->method()) 
    {   
        $user = ORM::factory('User')->login(
            $this->request->post('username'), 
            $this->request->post('password')
        );

        if ($user) 
        {
            $this->redirect('profile');
        } 
        else 
        {
            $message = 'Login failed';
        }
    }
}

But when I try to add the Model_User (extending Model_Auth_User), which is pretty basic:

class Model_User extends Model_Auth_User {}

I get the following error:

Call to undefined method Model_User::login()

Since the model extends module's core classes, isn't he supposed to include the login() method as well?

1

1 Answers

1
votes

You should replace ORM::factory('User') with Auth::instance() like this

$user = Auth::instance()->login($this->request->post('username'),$this->request->post('password'));