mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-06 20:50:01 +00:00
Fix non-object issue during addUser Job
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Jobs\VNet;
|
||||
|
||||
use App\Models\Node;
|
||||
use App\Models\User;
|
||||
use Arr;
|
||||
use Http;
|
||||
@@ -23,17 +24,17 @@ class addUser implements ShouldQueue
|
||||
private $data;
|
||||
private $nodes;
|
||||
|
||||
public function __construct($userIds, $nodes)
|
||||
public function __construct($userIds, $nodeIds)
|
||||
{
|
||||
$this->nodes = $nodes;
|
||||
$this->nodes = Node::findMany($nodeIds);
|
||||
$data = [];
|
||||
foreach (User::findMany($userIds) as $user) {
|
||||
$data[] = [
|
||||
'uid' => $user->id,
|
||||
'port' => $user->port,
|
||||
'passwd' => $user->passwd,
|
||||
'uid' => $user->id,
|
||||
'port' => $user->port,
|
||||
'passwd' => $user->passwd,
|
||||
'speed_limit' => $user->speed_limit,
|
||||
'enable' => $user->enable,
|
||||
'enable' => $user->enable,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -27,11 +27,11 @@ class editUser implements ShouldQueue
|
||||
{
|
||||
$this->nodes = $nodes;
|
||||
$this->data = [
|
||||
'uid' => $user->id,
|
||||
'port' => (int) $user->port,
|
||||
'passwd' => $user->passwd,
|
||||
'uid' => $user->id,
|
||||
'port' => (int) $user->port,
|
||||
'passwd' => $user->passwd,
|
||||
'speed_limit' => $user->speed_limit,
|
||||
'enable' => (int) $user->enable,
|
||||
'enable' => (int) $user->enable,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ class editUser implements ShouldQueue
|
||||
if ($list && in_array($this->data['uid'], $list)) {
|
||||
$this->send($host, $secret);
|
||||
} else {
|
||||
addUser::dispatchAfterResponse($this->data['uid'], $node);
|
||||
addUser::dispatch($this->data['uid'], $node->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,21 +31,21 @@ class reloadNode implements ShouldQueue
|
||||
$allSuccess = true;
|
||||
foreach ($this->nodes as $node) {
|
||||
$ret = $this->send(($node->server ?: $node->ip).':'.$node->push_port, $node->auth->secret, [
|
||||
'id' => $node->id,
|
||||
'port' => (string) $node->port,
|
||||
'passwd' => $node->passwd ?: '',
|
||||
'method' => $node->method,
|
||||
'protocol' => $node->protocol,
|
||||
'obfs' => $node->obfs,
|
||||
'id' => $node->id,
|
||||
'port' => (string) $node->port,
|
||||
'passwd' => $node->passwd ?: '',
|
||||
'method' => $node->method,
|
||||
'protocol' => $node->protocol,
|
||||
'obfs' => $node->obfs,
|
||||
'protocol_param' => $node->protocol_param,
|
||||
'obfs_param' => $node->obfs_param ?: '',
|
||||
'push_port' => $node->push_port,
|
||||
'single' => $node->single,
|
||||
'secret' => $node->auth->secret,
|
||||
'is_udp' => $node->is_udp,
|
||||
'speed_limit' => $node->getRawOriginal('speed_limit'),
|
||||
'client_limit' => $node->client_limit,
|
||||
'redirect_url' => (string) sysConfig('redirect_url'),
|
||||
'obfs_param' => $node->obfs_param ?: '',
|
||||
'push_port' => $node->push_port,
|
||||
'single' => $node->single,
|
||||
'secret' => $node->auth->secret,
|
||||
'is_udp' => $node->is_udp,
|
||||
'speed_limit' => $node->getRawOriginal('speed_limit'),
|
||||
'client_limit' => $node->client_limit,
|
||||
'redirect_url' => (string) sysConfig('redirect_url'),
|
||||
]);
|
||||
|
||||
if (! $ret) {
|
||||
|
||||
@@ -77,7 +77,7 @@ class NodeObserver
|
||||
}
|
||||
|
||||
if ($node->type == 4) {
|
||||
reloadNode::dispatchAfterResponse(Node::whereId($node->id)->get());
|
||||
reloadNode::dispatch(Node::whereId($node->id)->get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class RuleGroupObserver
|
||||
if ($ruleGroup->nodes && Arr::hasAny($changes, ['type', 'rules'])) {
|
||||
$nodes = Node::whereType(4)->whereIn('id', $ruleGroup->nodes)->get();
|
||||
if ($nodes->isNotEmpty()) {
|
||||
reloadNode::dispatchAfterResponse($nodes);
|
||||
reloadNode::dispatch($nodes);
|
||||
}
|
||||
} elseif ($ruleGroup->rules && Arr::exists($changes, 'nodes')) {
|
||||
$arrayDiff = array_merge(
|
||||
@@ -26,7 +26,7 @@ class RuleGroupObserver
|
||||
if ($arrayDiff) {
|
||||
$nodes = Node::whereType(4)->whereIn('id', $arrayDiff)->get();
|
||||
if ($nodes->isNotEmpty()) {
|
||||
reloadNode::dispatchAfterResponse($nodes);
|
||||
reloadNode::dispatch($nodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class UserGroupObserver
|
||||
{
|
||||
$nodes = Node::whereType(4)->whereIn('id', $userGroup->nodes)->get();
|
||||
if ($nodes->isNotEmpty()) {
|
||||
reloadNode::dispatchAfterResponse($nodes);
|
||||
reloadNode::dispatch($nodes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class UserGroupObserver
|
||||
->whereIn('id', array_diff($userGroup->nodes ?? [], $userGroup->getOriginal('nodes') ?? []))
|
||||
->get();
|
||||
if ($nodes->isNotEmpty()) {
|
||||
reloadNode::dispatchAfterResponse($nodes);
|
||||
reloadNode::dispatch($nodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ class UserObserver
|
||||
$subscribe->code = Helpers::makeSubscribeCode();
|
||||
$subscribe->save();
|
||||
|
||||
$allowNodes = Node::userAllowNodes($user->group_id, $user->level)->whereType(4)->get();
|
||||
if ($allowNodes->isNotEmpty()) {
|
||||
addUser::dispatchAfterResponse($user->id, $allowNodes);
|
||||
$allowNodes = Node::userAllowNodes($user->group_id, $user->level)->whereType(4)->pluck('id');
|
||||
if ($allowNodes) {
|
||||
addUser::dispatch($user->id, $allowNodes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class UserObserver
|
||||
$changes = $user->getChanges();
|
||||
$allowNodes = Node::userAllowNodes($user->group_id, $user->level)->whereType(4)->get();
|
||||
if ($allowNodes->isNotEmpty() && Arr::hasAny($changes, ['level', 'group_id', 'port', 'passwd', 'speed_limit', 'enable'])) {
|
||||
editUser::dispatchAfterResponse($user, $allowNodes);
|
||||
editUser::dispatch($user, $allowNodes);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@ class AuthServiceProvider extends ServiceProvider
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $policies = [// 'App\Model' => 'App\Policies\ModelPolicy',
|
||||
protected $policies = [
|
||||
// 'App\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,15 +22,29 @@ class RouteServiceProvider extends ServiceProvider
|
||||
*/
|
||||
protected $namespace = 'App\Http\Controllers';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map(): void
|
||||
public function map()
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,9 +54,12 @@ class RouteServiceProvider extends ServiceProvider
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapApiRoutes(): void
|
||||
protected function mapApiRoutes()
|
||||
{
|
||||
Route::prefix('api')->middleware('api')->namespace($this->namespace)->group(base_path('routes/api.php'));
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/api.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,8 +69,10 @@ class RouteServiceProvider extends ServiceProvider
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapWebRoutes(): void
|
||||
protected function mapWebRoutes()
|
||||
{
|
||||
Route::middleware('web')->namespace($this->namespace)->group(base_path('routes/web.php'));
|
||||
Route::middleware('web')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/web.php'));
|
||||
}
|
||||
}
|
||||
|
||||
3447
ca/cacert.pem
3447
ca/cacert.pem
File diff suppressed because it is too large
Load Diff
3920
ca/cacert_alipay.pem
3920
ca/cacert_alipay.pem
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user