I start to learn this framework. Faced a problem, when I try to authorize a user, an error flies:

ErrorException [Fatal Error]: Call to undefined method Model_User :: where () ); 76 $ user-> where ($ user-> unique_key ($ username), '=', $ username) -> find (); 77}

my authorization code itself

$auth = Auth::instance('orm'); //..... $user = ORM::factory('user'); $auth->login($email, $pas)) 

I inherit from Controller_My_Template it in turn from Controller_Template Q. How to fix the problem?

  • one
    check if you have the same Model_User and for what reason Kohana cannot find it - xEdelweiss
  • Thanks for the tip, it was redefined by me and there was no corresponding method). Corrected, but encountered another error. - naym
  • @naym, what is the new mistake? Can't login? - xEdelweiss
  • Database method list_columns is not supported by Kohana_Database_PDO found answer stackoverflow.com/questions/7314739/kohana-3-2-orm-and-pdo Did, but the error did not disappear. If you drive in a "fake" column name, then the DBMS swears that there is no such column, and when all of them are correctly specified, then the same error is naym
  • one
    $ pas - the password in "pure form" should be - kemerov4anin

3 answers 3

Comments are over.

When registering or authorizing using ORM, Kohana handles password hashing, so you just need to assign a password.
This is on condition that you have expanded the existing user model, and not redefined it.

In general, look at the authorization guide, do exactly as advised, and only then, if it works out, make your own changes.

  • * send password - kemerov4anin
  • one
    Transfer at authorization, assignment at registration. - xEdelweiss

Official documentation And do not reinvent the wheel;)

  • changed to $ login = Auth :: instance () -> login ($ this-> request-> post ('email'), $ pas); if ($ login) {...} but still the same error ( - naym
  • Did the ORM and auth modules in the bootstrap file connect? - kemerov4anin
  • @ kemerov4anin Needless to say. - naym 2:42 pm
  • And Model_User Kohanovsky or themselves redefined the class? - kemerov4anin

Take data from the form. There are helpers, I advise you to read about them. To take data from a form, Use this helper arr :: get (). For authentication, everything is simple, auth :: instance () -> login ($ login, $ password);