-
Notifications
You must be signed in to change notification settings - Fork 243
Expand file tree
/
Copy pathForgotPasswordController.php
More file actions
61 lines (51 loc) · 1.84 KB
/
Copy pathForgotPasswordController.php
File metadata and controls
61 lines (51 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace ProcessMaker\Http\Controllers\Auth;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Password;
use ProcessMaker\Http\Controllers\Controller;
use ProcessMaker\Models\User;
class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/
use SendsPasswordResetEmails;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Send a reset link to the given user.
* Blocked or inactive users will not receive the reset email for security reasons.
*
* @param Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
*/
public function sendResetLinkEmail(Request $request)
{
$this->validateEmail($request);
$user = User::where('email', $request->input('email'))->first();
if ($user && ($user->status === 'BLOCKED' || $user->status === 'INACTIVE')) {
return $this->sendResetLinkResponse($request, Password::RESET_LINK_SENT);
}
$response = $this->broker()->sendResetLink(
$this->credentials($request)
);
return $response == Password::RESET_LINK_SENT
? $this->sendResetLinkResponse($request, $response)
: $this->sendResetLinkFailedResponse($request, $response);
}
}