feat(auth): lock admin login per account as well as per IP

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
baodev0
2026-10-22 22:40:44 +07:00
co-authored by Claude Opus 5.5
parent 7f41c27958
commit fc765ad007
5 changed files with 138 additions and 34 deletions
@@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::dropIfExists('admin_login_blocks');
Schema::create('admin_login_blocks', function (Blueprint $table) {
$table->id();
$table->string('kind', 16);
$table->string('identifier', 191);
$table->unsignedInteger('failed_attempts')->default(0);
$table->string('last_username', 191)->nullable();
$table->string('last_ip', 45)->nullable();
$table->string('user_agent', 500)->nullable();
$table->timestamp('last_failed_at')->nullable();
$table->timestamp('blocked_until')->nullable()->index();
$table->timestamps();
$table->unique(['kind', 'identifier']);
});
}
public function down(): void
{
Schema::dropIfExists('admin_login_blocks');
Schema::create('admin_login_blocks', function (Blueprint $table) {
$table->id();
$table->string('ip', 45)->unique();
$table->unsignedInteger('failed_attempts')->default(0);
$table->string('last_username', 191)->nullable();
$table->string('user_agent', 500)->nullable();
$table->timestamp('last_failed_at')->nullable();
$table->timestamp('blocked_until')->nullable()->index();
$table->timestamps();
});
}
};