From 35362689c41153bde88b6fe83a2472bf3346116b Mon Sep 17 00:00:00 2001 From: tokumeikoi Date: Fri, 26 Mar 2021 02:20:53 +0900 Subject: [PATCH] update: config --- app/Http/Controllers/Admin/UserController.php | 26 +++++++++++++++++++ app/Http/Requests/Admin/ConfigSave.php | 3 ++- app/Http/Routes/AdminRoute.php | 1 + 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 799c441c..f7da32ea 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -265,4 +265,30 @@ class UserController extends Controller 'data' => true ]); } + + public function setInviteUser(Request $request) + { + $request->validate([ + 'user_id' => 'required|integer', + 'invite_user' => 'required', + ], [ + 'user_id.required' => '用户ID不能为空', + 'user_id.integer' => '用户ID参数有误', + 'invite_user.required' => '邀请人不能为空' + ]); + + $user = User::find($request->input('user_id')); + if (!$user) abort(500, '用户不存在'); + if (strpos($request->input('invite_user'), '@') !== -1) { + $inviteUser = User::where('email', $request->input('invite_user'))->first(); + } else { + $inviteUser = User::find($request->input('invite_user')); + } + if (!$inviteUser) abort(500, '邀请人不存在'); + $user->invite_user_id = $inviteUser->id; + + return response([ + 'data' => $user->save() + ]); + } } diff --git a/app/Http/Requests/Admin/ConfigSave.php b/app/Http/Requests/Admin/ConfigSave.php index caae9d33..fcc4e05b 100755 --- a/app/Http/Requests/Admin/ConfigSave.php +++ b/app/Http/Requests/Admin/ConfigSave.php @@ -120,7 +120,8 @@ class ConfigSave extends FormRequest // illiteracy prompt return [ 'app_url.url' => '站点URL格式不正确,必须携带http(s)://', - 'subscribe_url.url' => '订阅URL格式不正确,必须携带http(s)://' + 'subscribe_url.url' => '订阅URL格式不正确,必须携带http(s)://', + 'server_token.min' => '通讯密钥长度必须大于16位' ]; } } diff --git a/app/Http/Routes/AdminRoute.php b/app/Http/Routes/AdminRoute.php index 2a61e6a6..14ce195b 100644 --- a/app/Http/Routes/AdminRoute.php +++ b/app/Http/Routes/AdminRoute.php @@ -74,6 +74,7 @@ class AdminRoute $router->post('/user/sendMail', 'Admin\\UserController@sendMail'); $router->post('/user/ban', 'Admin\\UserController@ban'); $router->post('/user/resetSecret', 'Admin\\UserController@resetSecret'); + $router->post('/user/setInviteUser', 'Admin\\UserController@setInviteUser'); // StatOrder $router->get ('/stat/getOverride', 'Admin\\StatController@getOverride'); $router->get ('/stat/getServerLastRank', 'Admin\\StatController@getServerLastRank');