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