Skip to content

Commit

Permalink
修复没有uuid的问题
Browse files Browse the repository at this point in the history
跟随上游改uuid
  • Loading branch information
splendidmata committed Mar 14, 2021
1 parent 9015e83 commit c6a4830
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
6 changes: 0 additions & 6 deletions app/Command/Job.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
use App\Models\UnblockIp;
use Exception;
use RuntimeException;
use Ramsey\Uuid\Uuid;

class Job
{
Expand Down Expand Up @@ -611,11 +610,6 @@ public static function CheckJob()

$users = User::all();
foreach ($users as $user) {
$user->uuid = Uuid::uuid3(
Uuid::NAMESPACE_DNS,
strval($user->id) . '|' . $user->passwd
)->toString();
$user->save();
if (($user->transfer_enable <= $user->u + $user->d || $user->enable == 0 || (strtotime($user->expire_in) < time() && strtotime($user->expire_in) > 644447105)) && RadiusBan::where(
'userid',
$user->id
Expand Down
3 changes: 3 additions & 0 deletions app/Command/XCat.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use App\Utils\DNSoverHTTPS;
use Exception;
use TelegramBot\Api\BotApi;
use Ramsey\Uuid\Uuid;

class XCat
{
Expand Down Expand Up @@ -216,13 +217,15 @@ public function createAdmin()

if (strtolower($y) == 'y') {
echo 'start create admin account';
$current_timestamp = time();
// create admin user
// do reg user
$user = new User();
$user->user_name = 'admin';
$user->email = $email;
$user->pass = Hash::passwordHash($passwd);
$user->passwd = Tools::genRandomChar(6);
$user->uuid = Uuid::uuid3(Uuid::NAMESPACE_DNS, $email . '|' . $current_timestamp);
$user->port = Tools::getLastPort() + 1;
$user->t = 0;
$user->u = 0;
Expand Down
3 changes: 3 additions & 0 deletions app/Controllers/Admin/UserController.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use App\Utils\Radius;
use App\Utils\Tools;
use Exception;
use Ramsey\Uuid\Uuid;


class UserController extends AdminController
Expand Down Expand Up @@ -84,11 +85,13 @@ public function createNewUser($request, $response, $args)
}
// do reg user
$user = new User();
$current_timestamp = time();
$pass = Tools::genRandomChar();
$user->user_name = $email;
$user->email = $email;
$user->pass = Hash::passwordHash($pass);
$user->passwd = Tools::genRandomChar(6);
$user->uuid = Uuid::uuid3(Uuid::NAMESPACE_DNS, $email . '|' . $current_timestamp);
$user->port = Tools::getAvPort();
$user->t = 0;
$user->u = 0;
Expand Down
3 changes: 2 additions & 1 deletion app/Controllers/AuthController.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -592,14 +592,15 @@ public function registerHandle($request, $response)

// do reg user
$user = new User();

$antiXss = new AntiXSS();
$current_timestamp = time();


$user->user_name = $antiXss->xss_clean($name);
$user->email = $email;
$user->pass = Hash::passwordHash($passwd);
$user->passwd = Tools::genRandomChar(6);
$user->uuid = Uuid::uuid3(Uuid::NAMESPACE_DNS, $email . '|' . $current_timestamp);
$user->port = Tools::getAvPort();
$user->t = 0;
$user->u = 0;
Expand Down
15 changes: 13 additions & 2 deletions app/Controllers/UserController.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use App\Models\DetectRule;
use App\Models\NodeOnlineLog;
use App\Models\NodeInfoLog;
use Ramsey\Uuid\Uuid;

use Exception;
use voku\helper\AntiXSS;
Expand Down Expand Up @@ -1700,19 +1701,29 @@ public function updateSsPwd($request, $response, $args)
$user = Auth::getUser();
$pwd = $request->getParam('sspwd');
$pwd = trim($pwd);
$current_timestamp = time();
$new_uuid = Uuid::uuid3(Uuid::NAMESPACE_DNS,
$user->email . '|' . $current_timestamp);
$otheruuid = User::where('uuid', $new_uuid)->first();

if ($pwd == '') {
$res['ret'] = 0;
$res['msg'] = '密码不能为空';
return $response->getBody()->write(json_encode($res));
}

if (!Tools::is_validate($pwd)) {
$res['ret'] = 0;
$res['msg'] = '密码无效';
return $response->getBody()->write(json_encode($res));
}

if ($otheruuid != null) {
$res['ret'] = 0;
$res['msg'] = '目前出现一些问题,请稍后再试';
return $response->getBody()->write(json_encode($res));
}

$user->uuid = $new_uuid;
$user->save();
$user->updateSsPwd($pwd);
$res['ret'] = 1;

Expand Down

0 comments on commit c6a4830

Please sign in to comment.