脚本宝典收集整理的这篇文章主要介绍了php – Kohana Auth模块无法登录,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
public function user_create() { $user = ORM::factory('user'); $user->username = "user"; $this->auth = Auth::instance(); $user->email = "info@test.COM"; $user->password = $this->auth->hash_password('admin'); $user->add(ORM::factory('role','login')); $user->add(ORM::factory('role','admin')); if ($user->save()) { $this->template->tITle = "user saved"; $this->template->content = "user saved"; } }
它创建一个具有散列密码的用户,并为其提供正确的登录/管理员角色.数据库中的一切看起来都很好.这是我的登录代码.我跳过了检查用户是否已登录的开头部分.
$user = $this->input->post('username'); $password = $this->input->post('password'); if(!empty($user)) { $find_user = ORM::factory('user')->where('username',$user)->find(); $username = $find_user->username; $this->auth = Auth::instance(); if($this->auth->LOGin($username,$password)) { $error = "logged in"; } else { $error = "not logged in at all"; } } $this->template->content = new View('admin/login_view'); $this->template->content->user_info = $username . " " . $password; $this->template->title = "Login Admin"; $this->template->content->bind('error',$error);
它总是返回“根本没有登录”.我验证我输入了正确的用户名和密码,但它没有登录.我无法弄清楚原因.我正在使用内置的hash_password函数来创建密码,我已经按照文档,但我无法发现错误.有帮助吗?
public function user_create() { $user = ORM::factory('user'); $user->username = "user"; $this->auth = Auth::instance(); $user->email = "info@test.com"; $user->password = 'admin'; ...
希望有所帮助.如果你想查看auth模块(models / auth_user.PHP),你可以看到它记录了密码:
public function __set($key,$value) { if ($key === 'password') { // Use Auth to hash the password $value = Auth::instance()->hash_password($value); } parent::__set($key,$value); }
以上是脚本宝典为你收集整理的php – Kohana Auth模块无法登录全部内容,希望文章能够帮你解决php – Kohana Auth模块无法登录所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。