mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 09:21:46 +08:00 
			
		
		
		
	update: add register ip limit
This commit is contained in:
		| @@ -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', | ||||
|   | ||||
		Reference in New Issue
	
	Block a user