2018-06-17 16:53:24 -07:00
|
|
|
<?php
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2018-06-17 16:53:24 -07:00
|
|
|
namespace Pterodactyl\Http\Requests\Api\Client\Account;
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
use Illuminate\Support\Facades\Hash;
|
2018-06-17 16:53:24 -07:00
|
|
|
use Pterodactyl\Exceptions\Http\Base\InvalidPasswordProvidedException;
|
2026-10-05 18:10:18 -04:00
|
|
|
use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
|
|
|
|
|
use Pterodactyl\Support\JsonValueGuard;
|
|
|
|
|
use Pterodactyl\Validation\UserRules;
|
2018-06-17 16:53:24 -07:00
|
|
|
|
|
|
|
|
class UpdatePasswordRequest extends ClientApiRequest
|
|
|
|
|
{
|
|
|
|
|
/**
|
2026-10-05 18:10:18 -04:00
|
|
|
* @return ValidationRules
|
2018-06-17 16:53:24 -07:00
|
|
|
*/
|
|
|
|
|
public function rules(): array
|
|
|
|
|
{
|
2020-11-29 13:28:46 -08:00
|
|
|
return [
|
2026-10-05 18:10:18 -04:00
|
|
|
'current_password' => ['required', 'string'],
|
|
|
|
|
'password' => ['required', 'confirmed', ...UserRules::PASSWORD],
|
2020-11-29 13:28:46 -08:00
|
|
|
];
|
2018-06-17 16:53:24 -07:00
|
|
|
}
|
2026-10-05 18:10:18 -04:00
|
|
|
|
|
|
|
|
protected function passedValidation(): void
|
|
|
|
|
{
|
|
|
|
|
throw_unless(Hash::check(JsonValueGuard::string($this->validated('current_password')), $this->user()->password), InvalidPasswordProvidedException::class, trans('validation.internal.invalid_password'));
|
|
|
|
|
}
|
2018-06-17 16:53:24 -07:00
|
|
|
}
|