1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Front\Auth; |
4
|
|
|
|
5
|
|
|
use Auth; |
6
|
|
|
use Password; |
7
|
|
|
use Illuminate\Http\Request; |
8
|
|
|
use App\Services\Auth\Front\User; |
9
|
|
|
use App\Http\Controllers\Controller; |
10
|
|
|
use Illuminate\Foundation\Auth\ResetsPasswords; |
11
|
|
|
|
12
|
|
View Code Duplication |
class ResetPasswordController extends Controller |
|
|
|
|
13
|
|
|
{ |
14
|
|
|
protected $redirectTo = '/'; |
15
|
|
|
|
16
|
|
|
use ResetsPasswords; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Create a new controller instance. |
20
|
|
|
*/ |
21
|
|
|
public function __construct() |
22
|
|
|
{ |
23
|
|
|
$this->middleware('guest'); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Display the password reset view for the given token. |
28
|
|
|
* |
29
|
|
|
* If no token is present, display the link request form. |
30
|
|
|
* |
31
|
|
|
* @param \Illuminate\Http\Request $request |
32
|
|
|
* @param string|null $token |
33
|
|
|
* |
34
|
|
|
* @return \Illuminate\Http\Response |
35
|
|
|
*/ |
36
|
|
|
public function showResetForm(Request $request, $token = null) |
37
|
|
|
{ |
38
|
|
|
if (! $user = User::findByToken($token)) { |
39
|
|
|
flash()->error(trans('passwordReset.invalidToken')); |
|
|
|
|
40
|
|
|
|
41
|
|
|
return redirect()->to(login_url()); |
|
|
|
|
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
return view('front.auth.resetPassword')->with( |
|
|
|
|
45
|
|
|
['token' => $token, 'email' => $request->email, 'user' => $user] |
46
|
|
|
); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Get the response for a successful password reset. |
51
|
|
|
* |
52
|
|
|
* @param string $response |
53
|
|
|
* |
54
|
|
|
* @return \Illuminate\Http\Response |
55
|
|
|
*/ |
56
|
|
|
protected function sendResetResponse($response) |
57
|
|
|
{ |
58
|
|
|
flash()->info(trans($response)); |
|
|
|
|
59
|
|
|
|
60
|
|
|
return redirect($this->redirectPath()); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
protected function guard() |
64
|
|
|
{ |
65
|
|
|
return Auth::guard('front'); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Get the broker to be used during password reset. |
70
|
|
|
* |
71
|
|
|
* @return \Illuminate\Contracts\Auth\PasswordBroker |
72
|
|
|
*/ |
73
|
|
|
public function broker() |
74
|
|
|
{ |
75
|
|
|
return Password::broker('front'); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.