Files

39 lines
1.1 KiB
PHP
Raw Permalink Normal View History

<?php
2026-10-05 18:10:18 -04:00
declare(strict_types=1);
namespace Pterodactyl\Http\Requests\Api\Client\Account;
2026-10-05 18:10:18 -04:00
use Illuminate\Support\Facades\Hash;
2026-10-11 06:31:11 -04:00
use Pterodactyl\Actions\Users\CreateUser;
use Pterodactyl\Exceptions\Http\Base\InvalidPasswordProvidedException;
2026-10-05 18:10:18 -04:00
use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
class UpdateEmailRequest extends ClientApiRequest
{
2026-10-11 02:30:16 -04:00
/**
* The password is checked before validation runs, so the unique email rule cannot
* tell someone without it which addresses already belong to an account. A missing
* or malformed password is left to the rules below.
*/
public function authorize(): bool
{
$password = $this->input('password');
throw_if(is_string($password) && ! Hash::check($password, $this->user()->password), InvalidPasswordProvidedException::class, trans('validation.internal.invalid_password'));
return parent::authorize();
}
/**
2026-10-05 18:10:18 -04:00
* @return ValidationRules
*/
2026-10-05 18:10:18 -04:00
public function rules(): array
{
2026-10-05 18:10:18 -04:00
return [
2026-10-11 06:31:11 -04:00
'email' => CreateUser::rules($this->user())['email'],
2026-10-05 18:10:18 -04:00
'password' => ['required', 'string'],
];
}
}