Skip to content

Commit

Permalink
chore: update agent
Browse files Browse the repository at this point in the history
  • Loading branch information
BobCoderS9 committed Sep 8, 2023
1 parent 3f49bd4 commit ae7b246
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3,194 deletions.
9 changes: 5 additions & 4 deletions src/Metron/MtAgent.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function edit_user($request, $response, $args)
}

$edituser_config = $edituser->config;
if ($edituser_config['form_agent_create'] !== true) {
if (isset($edituser_config['form_agent_create']) && $edituser_config['form_agent_create'] !== true) {
return '您无权操作通过邀请链接或邀请码注册的用户';
}

Expand Down Expand Up @@ -113,7 +113,7 @@ public function edit_user_save($request, $response, $args)
}

$edituser_config = $edituser->config;
if ($edituser_config['form_agent_create'] !== true) {
if (isset($edituser_config['form_agent_create']) && $edituser_config['form_agent_create'] !== true) {
$res['ret'] = 0;
$res['msg'] = '您无权操作通过邀请链接或邀请码注册的用户';
return $response->getBody()->write(json_encode($res));
Expand Down Expand Up @@ -283,6 +283,7 @@ public function add_user_save($request, $response, $args)
}

$email = trim($request->getParam('email'));
$shop_id = $request->getParam('shop_id');
$email = strtolower($email);
$suffix = trim($request->getParam('email_suffix'));

Expand All @@ -309,7 +310,7 @@ public function add_user_save($request, $response, $args)
$res['msg'] = '邮箱已经被注册了';
return $response->getBody()->write(json_encode($res));
}

$current_timestamp = time();
$newuser = new User();
$pass = Tools::genRandomChar();
Expand All @@ -318,7 +319,7 @@ public function add_user_save($request, $response, $args)
$newuser->pass = Hash::passwordHash($pass);
$newuser->passwd = Tools::genRandomChar(16);
$newuser->uuid = Uuid::uuid3(Uuid::NAMESPACE_DNS, $email . '|' . $current_timestamp);
$newuser->port = Tools::getAvPort();
$newuser->port = 0;
$newuser->t = 0;
$newuser->u = 0;
$newuser->d = 0;
Expand Down
3 changes: 1 addition & 2 deletions src/Utils/Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ public static function getAvPort()
//检索User数据表现有port
if ($_ENV['min_port'] > 65535 || $_ENV['min_port'] <= 0 || $_ENV['max_port'] > 65535 || $_ENV['max_port'] <= 0) {
return 0;
}
else {
} else {
$det = User::pluck('port')->toArray();
$port = array_diff(range($_ENV['min_port'], $_ENV['max_port']), $det);
shuffle($port);
Expand Down
Loading

0 comments on commit ae7b246

Please sign in to comment.