Admin two-factor authentication (mandatory for admins), users:create command, operations handbook

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lars StommerandClaude Opus 5.5 committed 2026-10-22 16:52:44 +02:00
1 parent dea1029225
commit 13760f2c02
11 files changed
+353 -3

No files matched your search

+9
View File
@@ -32,9 +32,18 @@ public function definition(): array
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
'role' => UserRole::Admin,
'app_authentication_secret' => 'JBSWY3DPEHPK3PXP',
];
}
/**
* Indicate that the user has not set up two-factor authentication yet.
*/
public function withoutTwoFactor(): static
{
return $this->state(fn (): array => ['app_authentication_secret' => null]);
}
public function role(?UserRole $role): static
{
return $this->state(fn (): array => ['role' => $role]);
@@ -0,0 +1,29 @@
<?php
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::table('users', function (Blueprint $table) {
$table->text('app_authentication_secret')->nullable()->after('password');
$table->text('app_authentication_recovery_codes')->nullable()->after('app_authentication_secret');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(['app_authentication_secret', 'app_authentication_recovery_codes']);
});
}
};
+1 -1
View File
@@ -16,7 +16,7 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
User::factory()->create([
User::factory()->withoutTwoFactor()->create([
'name' => 'Admin',
'email' => 'admin@example.com',
'role' => UserRole::Admin,