1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace App\Http\Controllers\Api\Password; |
6
|
|
|
|
7
|
|
|
use App\Http\Requests\Api\Password\ForgottenRequest; |
8
|
|
|
use App\Models\User; |
9
|
|
|
use App\Notifications\User\PasswordReset; |
10
|
|
|
use Illuminate\Auth\Passwords\PasswordBrokerManager; |
|
|
|
|
11
|
|
|
use Illuminate\Contracts\Auth\PasswordBroker; |
|
|
|
|
12
|
|
|
use Illuminate\Contracts\Notifications\Dispatcher; |
|
|
|
|
13
|
|
|
use Illuminate\Contracts\Routing\ResponseFactory; |
|
|
|
|
14
|
|
|
use Illuminate\Contracts\Translation\Translator; |
|
|
|
|
15
|
|
|
|
16
|
|
|
final class Forgotten |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var \Illuminate\Auth\Passwords\PasswordBrokerManager |
20
|
|
|
*/ |
21
|
|
|
protected $passwordBrokerManager; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var \Illuminate\Contracts\Routing\ResponseFactory |
25
|
|
|
*/ |
26
|
|
|
protected $responseFactory; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var \Illuminate\Contracts\Translation\Translator |
30
|
|
|
*/ |
31
|
|
|
protected $translator; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var \Illuminate\Contracts\Notifications\Dispatcher |
35
|
|
|
*/ |
36
|
|
|
protected $notificationDispatcher; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Reset constructor. |
40
|
|
|
* |
41
|
|
|
* @param \Illuminate\Auth\Passwords\PasswordBrokerManager $passwordBrokerManager |
42
|
|
|
* @param \Illuminate\Contracts\Routing\ResponseFactory $responseFactory |
43
|
|
|
* @param \Illuminate\Contracts\Translation\Translator $translator |
44
|
|
|
* @param \Illuminate\Contracts\Notifications\Dispatcher $notificationDispatcher |
45
|
|
|
*/ |
46
|
|
|
public function __construct( |
47
|
|
|
PasswordBrokerManager $passwordBrokerManager, |
48
|
|
|
ResponseFactory $responseFactory, |
49
|
|
|
Translator $translator, |
50
|
|
|
Dispatcher $notificationDispatcher |
51
|
|
|
) { |
52
|
|
|
$this->passwordBrokerManager = $passwordBrokerManager; |
53
|
|
|
$this->responseFactory = $responseFactory; |
54
|
|
|
$this->translator = $translator; |
55
|
|
|
$this->notificationDispatcher = $notificationDispatcher; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param \App\Http\Requests\Api\Password\ForgottenRequest $request |
60
|
|
|
* @return \Illuminate\Http\JsonResponse |
|
|
|
|
61
|
|
|
*/ |
62
|
|
|
public function __invoke(ForgottenRequest $request) |
63
|
|
|
{ |
64
|
|
|
$user = User::query()->where('email', $request->input('email'))->first(); |
65
|
|
|
|
66
|
|
|
if ($user instanceof User) { |
67
|
|
|
$this->notificationDispatcher->send($user, |
68
|
|
|
new PasswordReset($this->getPasswordBroker()->createToken($user)) |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
// We'll always send a successful response so that an attack can't find |
73
|
|
|
// what email addresses exist in the application. |
74
|
|
|
return $this->responseFactory->json([ |
75
|
|
|
'message' => $this->translator->trans(PasswordBroker::RESET_LINK_SENT), |
76
|
|
|
]); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return \Illuminate\Contracts\Auth\PasswordBroker|\Illuminate\Auth\Passwords\PasswordBroker |
|
|
|
|
81
|
|
|
*/ |
82
|
|
|
protected function getPasswordBroker(): PasswordBroker |
83
|
|
|
{ |
84
|
|
|
return $this->passwordBrokerManager->broker('users'); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths