mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 09:39:10 +08:00
update: register ip limit
This commit is contained in:
parent
d4183d2c7f
commit
7c473d6325
@ -20,9 +20,11 @@ class AuthController extends Controller
|
||||
{
|
||||
public function register(AuthRegister $request)
|
||||
{
|
||||
$registerCountByIP = CacheKey::get('REGISTER_IP_RATE_LIMIT', $request->ip()) || 0;
|
||||
if ($registerCountByIP >= 3) {
|
||||
abort(500, __('Register frequently, please try again after 1 hour'));
|
||||
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) {
|
||||
abort(500, __('Register frequently, please try again after 1 hour'));
|
||||
}
|
||||
}
|
||||
if ((int)config('v2board.recaptcha_enable', 0)) {
|
||||
$recaptcha = new ReCaptcha(config('v2board.recaptcha_key'));
|
||||
@ -115,7 +117,10 @@ class AuthController extends Controller
|
||||
$request->session()->put('id', $user->id);
|
||||
$user->last_login_at = time();
|
||||
$user->save();
|
||||
Cache::put(CacheKey::get('REGISTER_IP_RATE_LIMIT', $request->ip()), $registerCountByIP + 1, 3600);
|
||||
|
||||
if ((int)config('v2board.register_limit_by_ip_enable', 0)) {
|
||||
Cache::put(CacheKey::get('REGISTER_IP_RATE_LIMIT', $request->ip()), (int)$registerCountByIP + 1, 3600);
|
||||
}
|
||||
return response()->json([
|
||||
'data' => $data
|
||||
]);
|
||||
|
Loading…
Reference in New Issue
Block a user