update: config

This commit is contained in:
tokumeikoi 2021-03-26 02:20:53 +09:00
parent b740998760
commit 35362689c4
3 changed files with 29 additions and 1 deletions

View File

@ -265,4 +265,30 @@ class UserController extends Controller
'data' => true '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()
]);
}
} }

View File

@ -120,7 +120,8 @@ class ConfigSave extends FormRequest
// illiteracy prompt // illiteracy prompt
return [ return [
'app_url.url' => '站点URL格式不正确必须携带http(s)://', 'app_url.url' => '站点URL格式不正确必须携带http(s)://',
'subscribe_url.url' => '订阅URL格式不正确必须携带http(s)://' 'subscribe_url.url' => '订阅URL格式不正确必须携带http(s)://',
'server_token.min' => '通讯密钥长度必须大于16位'
]; ];
} }
} }

View File

@ -74,6 +74,7 @@ class AdminRoute
$router->post('/user/sendMail', 'Admin\\UserController@sendMail'); $router->post('/user/sendMail', 'Admin\\UserController@sendMail');
$router->post('/user/ban', 'Admin\\UserController@ban'); $router->post('/user/ban', 'Admin\\UserController@ban');
$router->post('/user/resetSecret', 'Admin\\UserController@resetSecret'); $router->post('/user/resetSecret', 'Admin\\UserController@resetSecret');
$router->post('/user/setInviteUser', 'Admin\\UserController@setInviteUser');
// StatOrder // StatOrder
$router->get ('/stat/getOverride', 'Admin\\StatController@getOverride'); $router->get ('/stat/getOverride', 'Admin\\StatController@getOverride');
$router->get ('/stat/getServerLastRank', 'Admin\\StatController@getServerLastRank'); $router->get ('/stat/getServerLastRank', 'Admin\\StatController@getServerLastRank');