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
|
|
|
public function redirectTo() |
28
|
|
|
{ |
29
|
|
|
return backpack_url(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Create a new controller instance. |
34
|
|
|
* |
35
|
|
|
* @return void |
|
|
|
|
36
|
|
|
*/ |
37
|
|
|
public function __construct() |
38
|
|
|
{ |
39
|
|
|
$guard = backpack_guard_name(); |
40
|
|
|
|
41
|
|
|
$this->middleware("guest:$guard"); |
42
|
|
|
|
43
|
|
|
if (!backpack_users_have_email()) { |
44
|
|
|
abort(501, trans('backpack::base.no_email_column')); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
// where to redirect after password was reset |
48
|
|
|
$this->redirectTo = property_exists($this, 'redirectTo') ? $this->redirectTo : config('backpack.base.route_prefix', 'admin').'/dashboard'; |
|
|
|
|
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
// ------------------------------------------------------- |
52
|
|
|
// Laravel overwrites for loading backpack views |
53
|
|
|
// ------------------------------------------------------- |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Display the password reset view for the given token. |
57
|
|
|
* |
58
|
|
|
* If no token is present, display the link request form. |
59
|
|
|
* |
60
|
|
|
* @param \Illuminate\Http\Request $request |
61
|
|
|
* @param string|null $token |
62
|
|
|
* |
63
|
|
|
* @return \Illuminate\Http\Response |
64
|
|
|
*/ |
65
|
|
|
public function showResetForm(Request $request, $token = null) |
66
|
|
|
{ |
67
|
|
|
$this->data['title'] = trans('backpack::base.reset_password'); // set the page title |
68
|
|
|
|
69
|
|
|
return view('backpack::auth.passwords.reset', $this->data)->with( |
|
|
|
|
70
|
|
|
['token' => $token, 'email' => $request->email] |
71
|
|
|
); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Get the broker to be used during password reset. |
76
|
|
|
* |
77
|
|
|
* @return \Illuminate\Contracts\Auth\PasswordBroker |
78
|
|
|
*/ |
79
|
|
|
public function broker() |
80
|
|
|
{ |
81
|
|
|
$passwords = config('backpack.base.passwords', config('auth.defaults.passwords')); |
82
|
|
|
|
83
|
|
|
return Password::broker($passwords); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Get the guard to be used during password reset. |
88
|
|
|
* |
89
|
|
|
* @return \Illuminate\Contracts\Auth\StatefulGuard |
90
|
|
|
*/ |
91
|
|
|
protected function guard() |
92
|
|
|
{ |
93
|
|
|
return backpack_auth(); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
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.