|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Backpack\Base\app\Http\Controllers\Auth; |
|
4
|
|
|
|
|
5
|
|
|
use Backpack\Base\app\Http\Controllers\Controller; |
|
6
|
|
|
use Illuminate\Foundation\Auth\ResetsPasswords; |
|
7
|
|
|
use Illuminate\Http\Request; |
|
8
|
|
|
use Illuminate\Support\Facades\Password; |
|
9
|
|
|
|
|
10
|
|
|
class ResetPasswordController extends Controller |
|
11
|
|
|
{ |
|
12
|
|
|
protected $data = []; // the information we send to the view |
|
13
|
|
|
|
|
14
|
|
|
/* |
|
15
|
|
|
|-------------------------------------------------------------------------- |
|
16
|
|
|
| Password Reset Controller |
|
17
|
|
|
|-------------------------------------------------------------------------- |
|
18
|
|
|
| |
|
19
|
|
|
| This controller is responsible for handling password reset requests |
|
20
|
|
|
| and uses a simple trait to include this behavior. You're free to |
|
21
|
|
|
| explore this trait and override any methods you wish to tweak. |
|
22
|
|
|
| |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
use ResetsPasswords; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Create a new controller instance. |
|
29
|
|
|
* |
|
30
|
|
|
* @return void |
|
|
|
|
|
|
31
|
|
|
*/ |
|
32
|
|
View Code Duplication |
public function __construct() |
|
|
|
|
|
|
33
|
|
|
{ |
|
34
|
|
|
$guard = backpack_guard_name(); |
|
35
|
|
|
|
|
36
|
|
|
$this->middleware("guest:$guard"); |
|
37
|
|
|
|
|
38
|
|
|
// where to redirect after password was reset |
|
39
|
|
|
$this->redirectTo = property_exists($this, 'redirectTo') ? $this->redirectTo : config('backpack.base.route_prefix', 'admin').'/dashboard'; |
|
|
|
|
|
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
// ------------------------------------------------------- |
|
43
|
|
|
// Laravel overwrites for loading backpack views |
|
44
|
|
|
// ------------------------------------------------------- |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Display the password reset view for the given token. |
|
48
|
|
|
* |
|
49
|
|
|
* If no token is present, display the link request form. |
|
50
|
|
|
* |
|
51
|
|
|
* @param \Illuminate\Http\Request $request |
|
52
|
|
|
* @param string|null $token |
|
53
|
|
|
* |
|
54
|
|
|
* @return \Illuminate\Http\Response |
|
55
|
|
|
*/ |
|
56
|
|
|
public function showResetForm(Request $request, $token = null) |
|
57
|
|
|
{ |
|
58
|
|
|
$this->data['title'] = trans('backpack::base.reset_password'); // set the page title |
|
59
|
|
|
|
|
60
|
|
|
return view('backpack::auth.passwords.reset', $this->data)->with( |
|
|
|
|
|
|
61
|
|
|
['token' => $token, 'email' => $request->email] |
|
62
|
|
|
); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Get the broker to be used during password reset. |
|
67
|
|
|
* |
|
68
|
|
|
* @return \Illuminate\Contracts\Auth\PasswordBroker |
|
69
|
|
|
*/ |
|
70
|
|
|
public function broker() |
|
71
|
|
|
{ |
|
72
|
|
|
$passwords = config('backpack.base.passwords', config('auth.defaults.passwords')); |
|
73
|
|
|
|
|
74
|
|
|
return Password::broker($passwords); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Get the guard to be used during password reset. |
|
79
|
|
|
* |
|
80
|
|
|
* @return \Illuminate\Contracts\Auth\StatefulGuard |
|
81
|
|
|
*/ |
|
82
|
|
|
protected function guard() |
|
83
|
|
|
{ |
|
84
|
|
|
return backpack_auth(); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|
Adding a
@returnannotation 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.