Removes password from the volunteer registration form. Account creation is now deferred to the approval step: Backend: - Registration creates Person without User (user_id=null) - On approval, system finds or creates User by person.email - New accounts get a "set password" email with activation link - Existing accounts get a portal link email - Added registration_source column to persons (self/organizer) - Fuzzy name matching skipped for self-registered persons - person.email is always source of truth for account linking Frontend: - Registration form no longer collects password - Email check shows info alert with login suggestion - New wachtwoord-instellen.vue page for account activation - PasswordRequirements.vue component (reused on reset page) - Success page updated with activation messaging Tests: 837 passed (all updated for new flow) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
75 lines
2.1 KiB
PHP
75 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\CrowdType;
|
|
use App\Models\Event;
|
|
use App\Models\Person;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/** @extends Factory<Person> */
|
|
final class PersonFactory extends Factory
|
|
{
|
|
/** @return array<string, mixed> */
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'event_id' => Event::factory(),
|
|
'crowd_type_id' => CrowdType::factory(),
|
|
'first_name' => fake('nl_NL')->firstName(),
|
|
'last_name' => fake('nl_NL')->lastName(),
|
|
'date_of_birth' => fake()->dateTimeBetween('-40 years', '-18 years')->format('Y-m-d'),
|
|
'email' => fake()->unique()->safeEmail(),
|
|
'phone' => fake('nl_NL')->phoneNumber(),
|
|
'status' => 'pending',
|
|
'is_blacklisted' => false,
|
|
'custom_fields' => null,
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Override create to handle user_id which is not mass-assignable.
|
|
*
|
|
* @param array<string, mixed> $attributes
|
|
*/
|
|
public function create($attributes = [], ?\Illuminate\Database\Eloquent\Model $parent = null): Person|\Illuminate\Database\Eloquent\Collection
|
|
{
|
|
$userId = $attributes['user_id'] ?? null;
|
|
unset($attributes['user_id']);
|
|
|
|
$result = parent::create($attributes, $parent);
|
|
|
|
if ($userId !== null) {
|
|
$models = $result instanceof Person ? collect([$result]) : $result;
|
|
$models->each(function (Person $person) use ($userId): void {
|
|
$person->user_id = $userId;
|
|
$person->save();
|
|
});
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
public function approved(): static
|
|
{
|
|
return $this->state(fn () => ['status' => 'approved']);
|
|
}
|
|
|
|
public function rejected(): static
|
|
{
|
|
return $this->state(fn () => ['status' => 'rejected']);
|
|
}
|
|
|
|
public function selfRegistered(): static
|
|
{
|
|
return $this->state(fn () => ['registration_source' => 'self']);
|
|
}
|
|
|
|
public function organizerCreated(): static
|
|
{
|
|
return $this->state(fn () => ['registration_source' => 'organizer']);
|
|
}
|
|
}
|