1.优化/api/v1/getGameUrl接口,无需再验证password

This commit is contained in:
2026-05-26 09:43:28 +08:00
parent 77db2357ba
commit e0b303c5d4
5 changed files with 8 additions and 12 deletions

View File

@@ -124,7 +124,7 @@ class UserLogic
* @param int|null $adminId 创建新用户时关联的后台管理员IDsa_system_user.id可选
* @param int[]|null $adminIdsInTopDept 当前管理员顶级部门下的所有管理员ID用于按部门范围查找玩家为空时退化为仅按 username 查找
*/
public function loginByUsername(string $username, string $password, string $lang, float $coin, string $time, ?int $adminId = null, ?array $adminIdsInTopDept = null, ?int $deptId = null): array
public function loginByUsername(string $username, string $password, string $lang, float $coin, string $time, ?int $adminId = null, ?array $adminIdsInTopDept = null, ?int $deptId = null, bool $skipPasswordValidation = false): array
{
$username = trim($username);
if ($username === '') {
@@ -143,9 +143,11 @@ class UserLogic
if ((int) ($player->status ?? 1) === 0) {
throw new ApiException('Account is disabled and cannot log in');
}
$hashed = $this->hashPassword($password);
if ($player->password !== $hashed) {
throw new ApiException('Wrong password');
if (!$skipPasswordValidation) {
$hashed = $this->hashPassword($password);
if ($player->password !== $hashed) {
throw new ApiException('Wrong password');
}
}
$currentCoin = (float) $player->coin;
$player->coin = $currentCoin + $coin;