我正在创建一个新用户,然后尝试让他们登录,用户被保存在数据库中,他们的角色也被保存。虽然我从来没有点击重定向说他们已经登录。我已经调试了 Auth::Instance->login 并且我回来了FALSE
public function action_index()
{
$view = View::factory('index/home');
if( Request::current()->post() ):
$post = $_POST;
try {
$user = ORM::factory('User');
$user->username = $post['username'];
$user->password = $post["password"];
$user->email = $post["email"];
$user->logins = +1;
$user->save();
if ($user->saved() ):
$user->add('roles', ORM::factory('Role')->where('name', '=', 'login')->find());
$logged_in = Auth::instance()->login($post['username'], $post['password']);
echo Debug::vars($logged_in); exit;
if ($logged_in):
HTTP::redirect("/dashboard/");
endif;
endif;
} catch (Exception $e) {
echo Debug::vars($e); exit;
}
endif;
$index_page = $view->render();
$this->response->body($index_page);
}
配置
return array(
'driver' => 'ORM',
'hash_method' => 'sha256',
'hash_key' => 'bernardo',
'lifetime' => 1209600,
'session_type' => Session::$default,
'session_key' => 'auth_user',
);
哈希时密码可能有问题吗?