From 2ea750ecbdda8c953583e3e533252a8b456eb983 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 18 Nov 2019 18:41:33 +0800 Subject: [PATCH] update --- .env.example | 1 + app/Http/Controllers/Admin/ConfigController.php | 3 ++- app/Http/Controllers/Passport/LoginController.php | 8 ++++++-- app/Http/Controllers/Passport/RegisterController.php | 6 ++++-- app/Http/Requests/Admin/ConfigSave.php | 6 ++++-- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.env.example b/.env.example index 6708d456..b87e7c26 100755 --- a/.env.example +++ b/.env.example @@ -50,3 +50,4 @@ DEFAULT_INVITE_COMMISSION=10 DEFAULT_INVITE_GEN_LIMIT=5 DEFAULT_STOP_REGISTER=0 DEFAULT_EMAIL_VERIFY=0 +DEFAULT_INVITE_NEVER_EXPIRE=0 \ No newline at end of file diff --git a/app/Http/Controllers/Admin/ConfigController.php b/app/Http/Controllers/Admin/ConfigController.php index 803b22fb..5c53a03c 100755 --- a/app/Http/Controllers/Admin/ConfigController.php +++ b/app/Http/Controllers/Admin/ConfigController.php @@ -21,7 +21,8 @@ class ConfigController extends Controller 'invite' => [ 'invite_force' => (int)config('v2board.invite_force', env('DEFAULT_INVITE_FORCE')), 'invite_commission' => config('v2board.invite_commission', env('DEFAULT_INVITE_COMMISSION')), - 'invite_gen_limit' => config('v2board.invite_gen_limit', env('DEFAULT_INVITE_GEN_LIMIT')) + 'invite_gen_limit' => config('v2board.invite_gen_limit', env('DEFAULT_INVITE_GEN_LIMIT')), + 'invite_never_expire' => config('v2board.invite_never_expire', env('DEFAULT_NEVER_EXPIRE')) ], 'site' => [ 'stop_register' => (int)config('v2board.stop_register', env('DEFAULT_STOP_REGISTER')), diff --git a/app/Http/Controllers/Passport/LoginController.php b/app/Http/Controllers/Passport/LoginController.php index 8d5c94b2..c0b6ebc9 100755 --- a/app/Http/Controllers/Passport/LoginController.php +++ b/app/Http/Controllers/Passport/LoginController.php @@ -26,8 +26,12 @@ class LoginController extends Controller if ($user->is_admin) { $request->session()->put('is_admin', true); } - return response([ + $res = [ 'data' => true - ]); + ]; + if ($user->is_admin) { + $res['is_admin'] = true; + } + return response($res); } } diff --git a/app/Http/Controllers/Passport/RegisterController.php b/app/Http/Controllers/Passport/RegisterController.php index 6baf92f3..0407180c 100755 --- a/app/Http/Controllers/Passport/RegisterController.php +++ b/app/Http/Controllers/Passport/RegisterController.php @@ -54,8 +54,10 @@ class RegisterController extends Controller } } $user->invite_user_id = $inviteCode->user_id ? $inviteCode->user_id : null; - $inviteCode->status = 1; - $inviteCode->save(); + if (!(int)config('v2board.invite_never_expire', env('DEFAULT_INVITE_NEVER_EXPIRE'))) { + $inviteCode->status = 1; + $inviteCode->save(); + } } if (!$user->save()) { diff --git a/app/Http/Requests/Admin/ConfigSave.php b/app/Http/Requests/Admin/ConfigSave.php index 73d2c772..38c431cd 100755 --- a/app/Http/Requests/Admin/ConfigSave.php +++ b/app/Http/Requests/Admin/ConfigSave.php @@ -10,11 +10,12 @@ class ConfigSave extends FormRequest return [ 'invite_force', 'invite_commission', + 'invite_gen_limit', + 'invite_nerver_expire', 'stop_register', 'email_verify', 'app_name', 'app_url', - 'invite_gen_limit', 'server_token', // alipay 'alipay_enable', @@ -39,9 +40,10 @@ class ConfigSave extends FormRequest return [ 'invite_force' => 'in:0,1', 'invite_commission' => 'integer', + 'invite_gen_limit' => 'integer', + 'invite_nerver_expire' => 'in:0,1', 'stop_register' => 'in:0,1', 'email_verify' => 'in:0,1', - 'invite_gen_limit' => 'integer', 'server_token' => 'min:16', 'app_url' => 'url', // alipay