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