mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 17:24:10 +00:00
Add IdnEmail validation rule that converts IDN domains to Punycode via idn_to_ascii() before validating with FILTER_VALIDATE_EMAIL. Applied to all email fields: customers, members, profiles, admin users, customer portal profiles, and mail configuration. Includes unit tests for standard emails, IDN emails, and invalid inputs. Fixes #388
30 lines
682 B
PHP
30 lines
682 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use App\Rules\IdnEmail;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class AdminUserUpdateRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user()->isSuperAdmin();
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'name' => ['required', 'string'],
|
|
'email' => [
|
|
'required',
|
|
new IdnEmail,
|
|
Rule::unique('users')->ignore($this->route('user')),
|
|
],
|
|
'phone' => ['nullable', 'string'],
|
|
'password' => ['nullable', 'string', 'min:8'],
|
|
];
|
|
}
|
|
}
|