1
|
|
|
<?php |
2
|
|
|
namespace Afrittella\BackProject\Http\Controllers\Auth; |
3
|
|
|
|
4
|
|
|
use Afrittella\BackProject\Http\Controllers\Controller; |
5
|
|
|
|
6
|
|
|
use Illuminate\Foundation\Auth\SendsPasswordResetEmails; |
7
|
|
|
use Illuminate\Http\Request; |
8
|
|
|
use Illuminate\Support\Facades\Password; |
9
|
|
|
use Prologue\Alerts\Facades\Alert; |
10
|
|
|
|
11
|
|
|
class ForgotPasswordController extends Controller |
12
|
|
|
{ |
13
|
|
|
protected $data = []; // the information we send to the view |
14
|
|
|
|
15
|
|
|
use SendsPasswordResetEmails; |
16
|
|
|
/** |
17
|
|
|
* Create a new controller instance. |
18
|
|
|
* |
19
|
|
|
* @return void |
|
|
|
|
20
|
|
|
*/ |
21
|
|
|
public function __construct() |
22
|
|
|
{ |
23
|
|
|
$this->middleware('guest'); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Display the form to request a password reset link. |
28
|
|
|
* |
29
|
|
|
* @return \Illuminate\Http\Response |
30
|
|
|
*/ |
31
|
|
|
public function showLinkRequestForm() |
32
|
|
|
{ |
33
|
|
|
$this->data['title'] = trans('back-project::base.reset_password'); // set the page title |
34
|
|
|
return view('back-project::auth.passwords.email', $this->data); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function sendResetLinkEmail(Request $request) |
38
|
|
|
{ |
39
|
|
|
$this->validate($request, ['email' => 'required|email']); |
40
|
|
|
|
41
|
|
|
// We will send the password reset link to this user. Once we have attempted |
42
|
|
|
// to send the link, we will examine the response then see the message we |
43
|
|
|
// need to show to the user. Finally, we'll send out a proper response. |
44
|
|
|
$response = $this->broker()->sendResetLink( |
45
|
|
|
$request->only('email') |
46
|
|
|
); |
47
|
|
|
|
48
|
|
|
if ($response == Password::RESET_LINK_SENT) { |
49
|
|
|
Alert::add('success', trans('back-project::base.reset_password_email_sent'))->flash(); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
return $response == Password::RESET_LINK_SENT |
53
|
|
|
? $this->sendResetLinkResponse($response) |
54
|
|
|
: $this->sendResetLinkFailedResponse($request, $response); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.