Pergunta

New to kohana here. I have a task from my internship to make login system with kohana framework 3.2 . I also did it to insert,update and delete stuff with auto modeler ORM. I have some trouble now with kohana auth. I already have the database structure Imported and inserted an user in the 'users' table and give him a role in the 'roles_user' table.

Also created an Auth.php file in APP/config/ :

return array(

    'driver'       => 'AutoModeler_ORM',
    'hash_method'  => 'sha256',
    'hash_key'     => 'Somebiglonghaskeyofmixedcharacters102345567709',
    'lifetime'     => 1209600,
    'session_type' => Session::$default,
    'session_key'  => 'auth_user',
);

In my controller , I have a login function with the following code:

if ($_POST)
{
$post = $this->request->post();
$success = Auth::instance()->login($post['email'], $post['password']);

if ($success)
{
echo "Welcome!";
}
else
{
echo "Something goes wrong...";
}

}

I already have activated the modules in the bootstrap.

pastebin link to my role model : http://pastebin.com/bQYReETh pastebin link to my user model : http://pastebin.com/ufzvKjmA

The problem is that I always come in the else.

Does somebody have an idea whats going on? Do I miss something?

Foi útil?

Solução

@Woodle,

Maybe adding a _constructor can help.

public function __construct($id = NULL)
    {
        if ($id !== NULL)
        {
            $this->load(db::select_array($this->fields())->where($this->_table_name.'.username', '=', $id));
        }
        elseif ($this->id) // We loaded this via mysql_result_object
        {
            parent::__construct($id);
        }
    }
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top