mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 00:01:21 +00:00
Update themes, BasePage and Profile controllers
This commit is contained in:
@@ -4,7 +4,6 @@ namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\ForgottenPassword;
|
||||
use App\Mail\PasswordReset;
|
||||
use App\Models\Settings;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
@@ -37,68 +36,35 @@ class ForgotPasswordController extends Controller
|
||||
|
||||
public function showLinkRequestForm()
|
||||
{
|
||||
$action = request()->input('action') ?? 'view';
|
||||
|
||||
$email = $rssToken = $sent = $confirmed = '';
|
||||
|
||||
switch ($action) {
|
||||
case 'reset':
|
||||
if (! request()->has('guid')) {
|
||||
app('smarty.view')->assign('error', 'No reset code provided.');
|
||||
break;
|
||||
}
|
||||
|
||||
$ret = User::getByPassResetGuid(request()->input('guid'));
|
||||
if (! $ret) {
|
||||
app('smarty.view')->assign('error', 'Bad reset code provided.');
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// reset the password, inform the user, send out the email
|
||||
//
|
||||
User::updatePassResetGuid($ret['id'], '');
|
||||
$newpass = User::generatePassword();
|
||||
User::updatePassword($ret['id'], $newpass);
|
||||
|
||||
$to = $ret['email'];
|
||||
$onscreen = 'Your password has been reset to <strong>'.$newpass.'</strong> and sent to your e-mail address.';
|
||||
Mail::to($to)->send(new PasswordReset($ret['id'], $newpass));
|
||||
app('smarty.view')->assign('notice', $onscreen);
|
||||
$confirmed = true;
|
||||
break;
|
||||
|
||||
break;
|
||||
case 'submit':
|
||||
$email = request()->input('email') ?? '';
|
||||
$rssToken = request()->input('apikey') ?? '';
|
||||
if (empty($email) && empty($rssToken)) {
|
||||
app('smarty.view')->assign('error', 'Missing parameter(email and/or apikey to send password reset');
|
||||
} else {
|
||||
//
|
||||
// Check users exists and send an email
|
||||
//
|
||||
$ret = ! empty($rssToken) ? User::getByRssToken($rssToken) : User::getByEmail($email);
|
||||
if ($ret === null) {
|
||||
app('smarty.view')->assign('error', 'The email or apikey are not recognised.');
|
||||
$sent = true;
|
||||
break;
|
||||
}
|
||||
//
|
||||
// Generate a forgottenpassword guid, store it in the user table
|
||||
//
|
||||
$guid = md5(uniqid('', false));
|
||||
User::updatePassResetGuid($ret['id'], $guid);
|
||||
//
|
||||
// Send the email
|
||||
//
|
||||
$resetLink = request()->server('SERVER_NAME').'/forgottenpassword?action=reset&guid='.$guid;
|
||||
//Mail::to($ret['email'])->send(new ForgottenPassword($resetLink));
|
||||
$sent = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
$sent = '';
|
||||
$email = request()->input('email') ?? '';
|
||||
$rssToken = request()->input('apikey') ?? '';
|
||||
if (empty($email) && empty($rssToken)) {
|
||||
app('smarty.view')->assign('error', 'Missing parameter(email and/or apikey to send password reset');
|
||||
} else {
|
||||
//
|
||||
// Check users exists and send an email
|
||||
//
|
||||
$ret = ! empty($rssToken) ? User::getByRssToken($rssToken) : User::getByEmail($email);
|
||||
if ($ret === null) {
|
||||
app('smarty.view')->assign('error', 'The email or apikey are not recognised.');
|
||||
$sent = true;
|
||||
}
|
||||
//
|
||||
// Generate a forgottenpassword guid, store it in the user table
|
||||
//
|
||||
$guid = md5(uniqid('', false));
|
||||
User::updatePassResetGuid($ret['id'], $guid);
|
||||
//
|
||||
// Send the email
|
||||
//
|
||||
$resetLink = request()->server('SERVER_NAME').'/forgottenpassword?action=reset&guid='.$guid;
|
||||
Mail::to($ret['email'])->send(new ForgottenPassword($resetLink));
|
||||
$sent = true;
|
||||
}
|
||||
|
||||
|
||||
$theme = Settings::settingValue('site.main.style');
|
||||
|
||||
$title = 'Forgotten Password';
|
||||
@@ -117,7 +83,6 @@ class ForgotPasswordController extends Controller
|
||||
'meta_description' => $meta_description,
|
||||
'email' => $email,
|
||||
'apikey' => $rssToken,
|
||||
'confirmed' => $confirmed,
|
||||
'sent' => $sent,
|
||||
]
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user