feat: add user impersonation service
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('impersonation_logs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('admin_id')->constrained('users')->onDelete('cascade');
|
||||
$table->foreignId('target_user_id')->constrained('users')->onDelete('cascade');
|
||||
$table->timestamp('start_time');
|
||||
$table->timestamp('end_time')->nullable();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->enum('status', ['active', 'completed', 'force_terminated', 'expired'])->default('active');
|
||||
$table->json('pages_visited')->nullable();
|
||||
$table->json('actions_taken')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
// Indexes for performance
|
||||
$table->index(['admin_id', 'start_time']);
|
||||
$table->index(['target_user_id', 'start_time']);
|
||||
$table->index(['status', 'start_time']);
|
||||
$table->index(['ip_address']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('impersonation_logs');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user