1
|
|
|
<?php |
2
|
|
|
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Auth; |
4
|
|
|
|
5
|
|
|
use App\Http\Controllers\Auth\AuthController; |
6
|
|
|
use Illuminate\Foundation\Auth\ResetsPasswords; |
7
|
|
|
use Illuminate\Http\Request; |
8
|
|
|
use Facades\App\Services\WhichPortal; |
9
|
|
|
use App\Services\Validation\Rules\PasswordFormatRule; |
10
|
|
|
use Illuminate\Support\Facades\Lang; |
11
|
|
|
|
12
|
|
|
class ResetPasswordController extends AuthController |
|
|
|
|
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
|
|
|
* Where to redirect users after resetting their password. |
29
|
|
|
* |
30
|
|
|
* @var string |
31
|
|
|
*/ |
|
|
|
|
32
|
|
|
protected function redirectTo() |
33
|
|
|
{ |
34
|
|
|
$redirectTo = WhichPortal::isManagerPortal() ? route('manager.home') : route('home'); |
35
|
|
|
return $redirectTo; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Create a new controller instance. |
40
|
|
|
* |
41
|
|
|
* @return void |
42
|
|
|
*/ |
43
|
|
|
public function __construct() |
44
|
|
|
{ |
45
|
|
|
$this->middleware('guest'); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Display the password reset view for the given token. |
50
|
|
|
* |
51
|
|
|
* If no token is present, display the link request form. |
52
|
|
|
* |
53
|
|
|
* @param \Illuminate\Http\Request $request |
|
|
|
|
54
|
|
|
* @param string|null $token |
|
|
|
|
55
|
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
|
|
|
|
56
|
|
|
*/ |
57
|
|
|
public function showResetForm(Request $request, $token = null) |
58
|
|
|
{ |
59
|
|
|
return view('auth.passwords.reset')->with([ |
|
|
|
|
60
|
|
|
'token' => $token, |
61
|
|
|
'email' => strtolower($request->email), |
62
|
|
|
'routes' => $this->auth_routes(), |
63
|
|
|
'reset_password_template' => Lang::get('common/auth/reset_password'), |
64
|
|
|
]); |
|
|
|
|
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* OVERRIDE |
69
|
|
|
* Get the password reset validation rules. |
70
|
|
|
* |
71
|
|
|
* @return array |
72
|
|
|
*/ |
73
|
|
|
protected function rules() |
74
|
|
|
{ |
75
|
|
|
return [ |
76
|
|
|
'token' => 'required', |
77
|
|
|
'email' => 'required|email', |
78
|
|
|
'password' => [ |
79
|
|
|
'required', |
80
|
|
|
'min:8', |
81
|
|
|
new PasswordFormatRule, |
82
|
|
|
'confirmed' |
83
|
|
|
], |
84
|
|
|
]; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* OVERRIDE |
89
|
|
|
* Get the password reset validation error messages. |
90
|
|
|
* |
91
|
|
|
* @return array |
92
|
|
|
*/ |
93
|
|
|
protected function validationErrorMessages() |
94
|
|
|
{ |
95
|
|
|
return []; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* OVERRIDE |
100
|
|
|
* Get the password reset credentials from the request, with case insensitive email |
101
|
|
|
* |
102
|
|
|
* @param \Illuminate\Http\Request $request |
|
|
|
|
103
|
|
|
* @return array |
|
|
|
|
104
|
|
|
*/ |
105
|
|
|
protected function credentials(Request $request) |
106
|
|
|
{ |
107
|
|
|
$credentials = $request->only( |
108
|
|
|
'email', |
109
|
|
|
'password', |
110
|
|
|
'password_confirmation', |
111
|
|
|
'token' |
112
|
|
|
); |
113
|
|
|
if (isset($credentials['email'])) { |
114
|
|
|
$credentials['email'] = strtolower($credentials['email']); |
115
|
|
|
} |
116
|
|
|
return $credentials; |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|