fix: 修复节点密钥包含特殊字符时校验失败的问题

This commit is contained in:
xboard 2024-04-15 00:01:14 +08:00
parent 0c2360972b
commit 2eb81924e4

View File

@ -24,7 +24,14 @@ class Server
'hysteria2' => 'hysteria' 'hysteria2' => 'hysteria'
]; ];
$request->validate([ $request->validate([
'token' => ['required', 'string', 'in:' . admin_setting('server_token')], 'token' => [
"string",
function ($attribute, $value, $fail) {
if ($value !== admin_setting('server_token')) {
$fail('The ' . $attribute . ' is invalid.');
}
},
],
'node_id' => 'required', 'node_id' => 'required',
'node_type' => [ 'node_type' => [
'nullable', 'nullable',
@ -34,7 +41,6 @@ class Server
}, },
] ]
], [ ], [
'token.in' => 'Token is error!',
'node_type.regex' => 'node_type is error!' 'node_type.regex' => 'node_type is error!'
]); ]);
$nodeInfo = ServerService::getServer($request->input('node_id'), $request->input('node_type') ?? $node_type); $nodeInfo = ServerService::getServer($request->input('node_id'), $request->input('node_type') ?? $node_type);