Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Http/Requests/Api/Client/Account/UpdatePasswordRequest.php
10283 views
1
<?php
2
3
namespace Pterodactyl\Http\Requests\Api\Client\Account;
4
5
use Illuminate\Container\Container;
6
use Illuminate\Contracts\Hashing\Hasher;
7
use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
8
use Pterodactyl\Exceptions\Http\Base\InvalidPasswordProvidedException;
9
10
class UpdatePasswordRequest extends ClientApiRequest
11
{
12
/**
13
* @throws InvalidPasswordProvidedException
14
*/
15
public function authorize(): bool
16
{
17
if (!parent::authorize()) {
18
return false;
19
}
20
21
$hasher = Container::getInstance()->make(Hasher::class);
22
23
// Verify password matches when changing password or email.
24
if (!$hasher->check($this->input('current_password'), $this->user()->password)) {
25
throw new InvalidPasswordProvidedException(trans('validation.internal.invalid_password'));
26
}
27
28
return true;
29
}
30
31
public function rules(): array
32
{
33
return [
34
'password' => ['required', 'string', 'confirmed', 'min:8'],
35
];
36
}
37
}
38
39