|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Auth; |
|
4
|
|
|
|
|
5
|
|
|
use App\Http\Controllers\Controller; |
|
6
|
|
|
use App\Jobs\SendPasswordResetEmail; |
|
7
|
|
|
use App\Models\Settings; |
|
8
|
|
|
use App\Models\User; |
|
9
|
|
|
use Illuminate\Foundation\Auth\ResetsPasswords; |
|
10
|
|
|
use Illuminate\Http\Request; |
|
11
|
|
|
|
|
12
|
|
|
class ResetPasswordController extends Controller |
|
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 $redirectTo = '/'; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Create a new controller instance. |
|
36
|
|
|
* |
|
37
|
|
|
* @return void |
|
38
|
|
|
*/ |
|
39
|
|
|
public function __construct() |
|
40
|
|
|
{ |
|
41
|
|
|
$this->middleware('guest'); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @param \Illuminate\Http\Request $request |
|
46
|
|
|
* |
|
47
|
|
|
* @throws \Exception |
|
48
|
|
|
*/ |
|
49
|
|
|
public function reset(Request $request) |
|
50
|
|
|
{ |
|
51
|
|
|
$error = ''; |
|
52
|
|
|
$confirmed = ''; |
|
53
|
|
|
$onscreen = ''; |
|
54
|
|
|
if ($request->missing('guid')) { |
|
55
|
|
|
$error = 'No reset code provided.'; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
if ($error === '') { |
|
59
|
|
|
$ret = User::getByPassResetGuid($request->input('guid')); |
|
60
|
|
|
if ($ret === null) { |
|
61
|
|
|
$error = 'Bad reset code provided.'; |
|
62
|
|
|
} else { |
|
63
|
|
|
|
|
64
|
|
|
// |
|
65
|
|
|
// reset the password, inform the user, send out the email |
|
66
|
|
|
// |
|
67
|
|
|
User::updatePassResetGuid($ret['id'], ''); |
|
68
|
|
|
$newpass = User::generatePassword(); |
|
69
|
|
|
User::updatePassword($ret['id'], $newpass); |
|
70
|
|
|
|
|
71
|
|
|
$onscreen = 'Your password has been reset to <strong>'.$newpass.'</strong> and sent to your e-mail address.'; |
|
72
|
|
|
SendPasswordResetEmail::dispatch($ret, $newpass); |
|
73
|
|
|
$confirmed = true; |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
$theme = Settings::settingValue('site.main.style'); |
|
78
|
|
|
|
|
79
|
|
|
$title = 'Forgotten Password'; |
|
80
|
|
|
$meta_title = 'Forgotten Password'; |
|
81
|
|
|
$meta_keywords = 'forgotten,password,signup,registration'; |
|
82
|
|
|
$meta_description = 'Forgotten Password'; |
|
83
|
|
|
|
|
84
|
|
|
$content = app('smarty.view')->fetch($theme.'/forgottenpassword.tpl'); |
|
85
|
|
|
|
|
86
|
|
|
app('smarty.view')->assign( |
|
87
|
|
|
[ |
|
88
|
|
|
'content' => $content, |
|
89
|
|
|
'title' => $title, |
|
90
|
|
|
'meta_title' => $meta_title, |
|
91
|
|
|
'meta_keywords' => $meta_keywords, |
|
92
|
|
|
'meta_description' => $meta_description, |
|
93
|
|
|
'email' => $ret['email'] ?? '', |
|
94
|
|
|
'confirmed' => $confirmed, |
|
95
|
|
|
'error' => $error, |
|
96
|
|
|
'notice' => $onscreen, |
|
97
|
|
|
] |
|
98
|
|
|
); |
|
99
|
|
|
app('smarty.view')->display($theme.'/basepage.tpl'); |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|