+ Add su function.

This commit is contained in:
zhujinyong
2022-01-12 07:25:41 +08:00
parent 80e0f37c83
commit 4b17d8a8a4
2 changed files with 18 additions and 1 deletions
+15
View File
@@ -175,3 +175,18 @@ function zdImport($table, $yaml, $count = 10)
$command = "$config->zdPath -c $yaml -t $table -T -dns $dns --clear -n $count";
system($command);
}
/**
* Switch user.
*
* @param string $account
* @access public
* @return bool
*/
function su($account)
{
$userModel = new userModel();
$user = $userModel->identify($account, '123qwe!@#');
if($user) return $userModel->login($user);
return false;
}
+3 -1
View File
@@ -2,6 +2,8 @@
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
su('admin');
/**
title=测试 userModel::getById();
@@ -23,4 +25,4 @@ r($user->getByID('account1')) && p('account') && e('account1'); //
r($user->getByID(1)) && p('account') && e(''); // 通过默认字段获取不存在的用户
r($user->getByID(100000, 'id')) && p('account') && e(''); // 通过id字段获取不存在的用户
r($user->getByID('error', 'account')) && p('account') && e(''); // 通过默认字段获取不存在的用户
*/
*/