+ Add su function.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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(''); // 通过默认字段获取不存在的用户
|
||||
*/
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user