问题描述
我用的是无脂框架,里面有授权插件。
我连接了它,一切正常https://fatfreeframework.com/3.7/auth
要输入用户名和密码,我使用框架的现成形式,$auth->basic method();
该方法返回 true 或 false。
$db = new \DB\sql ('MysqL:host=localhost;dbname=project1','root','topsecret123');
$user = new \DB\sql\Mapper($db,'users');
$auth = new \authorize ($user,array('userid identificator=>",'PW'=>'password'));
$auth - >basic (); / / you will be prompted to log in to the network to authenticate the user
解决方法
你可以使用这个类似的代码。
function userAuth() {
$f3 = \Base::instance();
$mapper = new DB\SQL\Mapper($f3->DB,'users_tbl');
$auth = new \Auth($mapper,array('id' => 'email_mysql_col','pw' => 'password_mysqlcol'));
// if($auth->basic()) { // You can use callback,or just leave blank
if($auth->basic('passwordAuth_callback')) {
return true;
} else {
return false;
}
}
function passwordAuth_callback($pw) {
$f3 = \Base::instance();
return md5($f3->SALT . $pw);
}