mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 09:39:10 +08:00
update: add register ip limit
This commit is contained in:
parent
7c473d6325
commit
e3ffdb7bce
@ -103,7 +103,10 @@ class ConfigController extends Controller
|
||||
'recaptcha_site_key' => config('v2board.recaptcha_site_key'),
|
||||
'tos_url' => config('v2board.tos_url'),
|
||||
'currency' => config('v2board.currency', 'CNY'),
|
||||
'currency_symbol' => config('v2board.currency_symbol', '¥')
|
||||
'currency_symbol' => config('v2board.currency_symbol', '¥'),
|
||||
'register_limit_by_ip_enable' => config('v2board.register_limit_by_ip_enable', 0),
|
||||
'register_limit_count' => config('v2board.register_limit_count', 3),
|
||||
'register_limit_expire' => config('v2board.register_limit_expire', 60)
|
||||
],
|
||||
'subscribe' => [
|
||||
'plan_change_enable' => (int)config('v2board.plan_change_enable', 1),
|
||||
|
@ -22,7 +22,7 @@ class AuthController extends Controller
|
||||
{
|
||||
if ((int)config('v2board.register_limit_by_ip_enable', 0)) {
|
||||
$registerCountByIP = Cache::get(CacheKey::get('REGISTER_IP_RATE_LIMIT', $request->ip())) ?? 0;
|
||||
if ((int)$registerCountByIP >= 3) {
|
||||
if ((int)$registerCountByIP >= (int)config('v2board.register_limit_count', 3)) {
|
||||
abort(500, __('Register frequently, please try again after 1 hour'));
|
||||
}
|
||||
}
|
||||
@ -119,7 +119,11 @@ class AuthController extends Controller
|
||||
$user->save();
|
||||
|
||||
if ((int)config('v2board.register_limit_by_ip_enable', 0)) {
|
||||
Cache::put(CacheKey::get('REGISTER_IP_RATE_LIMIT', $request->ip()), (int)$registerCountByIP + 1, 3600);
|
||||
Cache::put(
|
||||
CacheKey::get('REGISTER_IP_RATE_LIMIT', $request->ip()),
|
||||
(int)$registerCountByIP + 1,
|
||||
(int)config('v2board.register_limit_expire', 60) * 60
|
||||
);
|
||||
}
|
||||
return response()->json([
|
||||
'data' => $data
|
||||
|
@ -48,6 +48,9 @@ class ConfigSave extends FormRequest
|
||||
'tos_url' => 'nullable|url',
|
||||
'currency' => '',
|
||||
'currency_symbol' => '',
|
||||
'register_limit_by_ip_enable' => 'in:0,1',
|
||||
'register_limit_count' => 'integer',
|
||||
'register_limit_expire' => 'integer',
|
||||
// subscribe
|
||||
'plan_change_enable' => 'in:0,1',
|
||||
'reset_traffic_method' => 'in:0,1,2',
|
||||
|
@ -237,5 +237,5 @@ return [
|
||||
| The only modification by laravel config
|
||||
|
|
||||
*/
|
||||
'version' => '1.5.6.1646831826955'
|
||||
'version' => '1.5.6.1648559460502'
|
||||
];
|
||||
|
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