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