mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 09:39:10 +08:00
feature: multiple ban
This commit is contained in:
parent
16ae59c992
commit
07cc8275d8
@ -215,9 +215,9 @@ class UserController extends Controller
|
||||
{
|
||||
$sortType = in_array($request->input('sort_type'), ['ASC', 'DESC']) ? $request->input('sort_type') : 'DESC';
|
||||
$sort = $request->input('sort') ? $request->input('sort') : 'created_at';
|
||||
$userModel = User::orderBy($sort, $sortType);
|
||||
$this->filter($request, $userModel);
|
||||
$users = $userModel->get();
|
||||
$builder = User::orderBy($sort, $sortType);
|
||||
$this->filter($request, $builder);
|
||||
$users = $builder->get();
|
||||
foreach ($users as $user) {
|
||||
SendEmailJob::dispatch([
|
||||
'email' => $user->email,
|
||||
@ -235,4 +235,23 @@ class UserController extends Controller
|
||||
'data' => true
|
||||
]);
|
||||
}
|
||||
|
||||
public function ban(Request $request)
|
||||
{
|
||||
$sortType = in_array($request->input('sort_type'), ['ASC', 'DESC']) ? $request->input('sort_type') : 'DESC';
|
||||
$sort = $request->input('sort') ? $request->input('sort') : 'created_at';
|
||||
$builder = User::orderBy($sort, $sortType);
|
||||
$this->filter($request, $builder);
|
||||
try {
|
||||
$builder->update([
|
||||
'banned' => 1
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
abort(500, '处理失败');
|
||||
}
|
||||
|
||||
return response([
|
||||
'data' => true
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -139,6 +139,10 @@ class AuthController extends Controller
|
||||
$request->session()->put('is_admin', true);
|
||||
$data['is_admin'] = true;
|
||||
}
|
||||
if ($user->is_staff) {
|
||||
$request->session()->put('is_staff', true);
|
||||
$data['is_staff'] = true;
|
||||
}
|
||||
return response([
|
||||
'data' => $data
|
||||
]);
|
||||
@ -185,7 +189,7 @@ class AuthController extends Controller
|
||||
{
|
||||
$user = User::where('token', $request->input('token'))->first();
|
||||
if (!$user) {
|
||||
abort(500, '用户不存在');
|
||||
abort(500, '令牌有误');
|
||||
}
|
||||
|
||||
$code = Helper::guid();
|
||||
@ -196,6 +200,27 @@ class AuthController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function getQuickLoginUrl(Request $request)
|
||||
{
|
||||
$user = User::where('token', $request->input('token'))->first();
|
||||
if (!$user) {
|
||||
abort(500, '令牌有误');
|
||||
}
|
||||
|
||||
$code = Helper::guid();
|
||||
$key = CacheKey::get('TEMP_TOKEN', $code);
|
||||
Cache::put($key, $user->id, 60);
|
||||
$redirect = '/#/login?verify=' . $code . '&redirect=' . ($request->input('redirect') ? $request->input('redirect') : 'dashboard');
|
||||
if (config('v2board.app_url')) {
|
||||
$url = config('v2board.app_url') . $redirect;
|
||||
} else {
|
||||
$url = url($redirect);
|
||||
}
|
||||
return response([
|
||||
'data' => $url
|
||||
]);
|
||||
}
|
||||
|
||||
public function check(Request $request)
|
||||
{
|
||||
$data = [
|
||||
|
@ -54,7 +54,6 @@ class UserController extends Controller
|
||||
'last_login_at',
|
||||
'created_at',
|
||||
'banned',
|
||||
'is_admin',
|
||||
'remind_expire',
|
||||
'remind_traffic',
|
||||
'expired_at',
|
||||
|
@ -70,6 +70,7 @@ class AdminRoute
|
||||
$router->post('/user/generate', 'Admin\\UserController@generate');
|
||||
$router->post('/user/dumpCSV', 'Admin\\UserController@dumpCSV');
|
||||
$router->post('/user/sendMail', 'Admin\\UserController@sendMail');
|
||||
$router->post('/user/ban', 'Admin\\UserController@ban');
|
||||
// Stat
|
||||
$router->get ('/stat/getOverride', 'Admin\\StatController@getOverride');
|
||||
// Notice
|
||||
|
@ -17,6 +17,7 @@ class PassportRoute
|
||||
$router->get ('/auth/check', 'Passport\\AuthController@check');
|
||||
$router->post('/auth/forget', 'Passport\\AuthController@forget');
|
||||
$router->post('/auth/getTempToken', 'Passport\\AuthController@getTempToken');
|
||||
$router->post('/auth/getQuickLoginUrl', 'Passport\\AuthController@getQuickLoginUrl');
|
||||
// Comm
|
||||
$router->get ('/comm/config', 'Passport\\CommController@config');
|
||||
$router->post('/comm/sendEmailVerify', 'Passport\\CommController@sendEmailVerify');
|
||||
|
@ -288,7 +288,6 @@ CREATE TABLE `v2_user` (
|
||||
`u` bigint(20) NOT NULL DEFAULT '0',
|
||||
`d` bigint(20) NOT NULL DEFAULT '0',
|
||||
`transfer_enable` bigint(20) NOT NULL DEFAULT '0',
|
||||
`enable` tinyint(1) NOT NULL DEFAULT '1',
|
||||
`banned` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`is_admin` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`is_staff` tinyint(1) NOT NULL DEFAULT '0',
|
||||
|
2
public/assets/admin/umi.js
vendored
2
public/assets/admin/umi.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user