mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 00:01:21 +00:00
Start using blade and tailwindcss
This commit is contained in:
@@ -35,71 +35,45 @@ class ForgotPasswordController extends Controller
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function showLinkRequestForm(Request $request): void
|
||||
public function showLinkRequestForm(Request $request)
|
||||
{
|
||||
$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 {
|
||||
if (config('captcha.enabled') === true && (! empty(config('captcha.secret')) && ! empty(config('captcha.sitekey')))) {
|
||||
$validate = Validator::make($request->all(), [
|
||||
'g-recaptcha-response' => 'required|captcha',
|
||||
]);
|
||||
if ($validate->fails()) {
|
||||
app('smarty.view')->assign('error', 'Captcha validation failed.');
|
||||
}
|
||||
}
|
||||
//
|
||||
// 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.');
|
||||
} else {
|
||||
// Check if user is soft deleted
|
||||
$user = User::withTrashed()->find($ret['id']);
|
||||
if ($user && $user->trashed()) {
|
||||
app('smarty.view')->assign('error', 'This account has been deactivated.');
|
||||
} else {
|
||||
//
|
||||
// Generate a forgottenpassword guid, store it in the user table
|
||||
//
|
||||
$guid = Str::random(32);
|
||||
User::updatePassResetGuid($ret['id'], $guid);
|
||||
//
|
||||
// Send the email
|
||||
//
|
||||
$resetLink = url('/').'/resetpassword?guid='.$guid;
|
||||
SendPasswordForgottenEmail::dispatch($ret, $resetLink);
|
||||
app('smarty.view')->assign('success', 'Password reset email has been sent!');
|
||||
}
|
||||
}
|
||||
$sent = true;
|
||||
return view('auth.passwords.email')->withErrors(['error' => 'Missing parameter (email and/or apikey) to send password reset']);
|
||||
}
|
||||
|
||||
$theme = 'Gentele';
|
||||
if (config('captcha.enabled') === true && (! empty(config('captcha.secret')) && ! empty(config('captcha.sitekey')))) {
|
||||
$validate = Validator::make($request->all(), [
|
||||
'g-recaptcha-response' => 'required|captcha',
|
||||
]);
|
||||
if ($validate->fails()) {
|
||||
return view('auth.passwords.email')->withErrors(['error' => 'Captcha validation failed.']);
|
||||
}
|
||||
}
|
||||
|
||||
$title = 'Forgotten Password';
|
||||
$meta_title = 'Forgotten Password';
|
||||
$meta_keywords = 'forgotten,password,signup,registration';
|
||||
$meta_description = 'Forgotten Password';
|
||||
// Check users exists and send an email
|
||||
$ret = ! empty($rssToken) ? User::getByRssToken($rssToken) : User::getByEmail($email);
|
||||
if ($ret === null) {
|
||||
return view('auth.passwords.email')->withErrors(['error' => 'The email or apikey are not recognised.']);
|
||||
}
|
||||
|
||||
$content = app('smarty.view')->fetch($theme.'/forgottenpassword.tpl');
|
||||
// Check if user is soft deleted
|
||||
$user = User::withTrashed()->find($ret['id']);
|
||||
if ($user && $user->trashed()) {
|
||||
return view('auth.passwords.email')->withErrors(['error' => 'This account has been deactivated.']);
|
||||
}
|
||||
|
||||
app('smarty.view')->assign(
|
||||
[
|
||||
'content' => $content,
|
||||
'title' => $title,
|
||||
'meta_title' => $meta_title,
|
||||
'meta_keywords' => $meta_keywords,
|
||||
'meta_description' => $meta_description,
|
||||
'email' => $email,
|
||||
'apikey' => $rssToken,
|
||||
'sent' => $sent,
|
||||
]
|
||||
);
|
||||
app('smarty.view')->display($theme.'/basepage.tpl');
|
||||
// Generate a forgottenpassword guid, store it in the user table
|
||||
$guid = Str::random(32);
|
||||
User::updatePassResetGuid($ret['id'], $guid);
|
||||
|
||||
// Send the email
|
||||
$resetLink = url('/').'/resetpassword?guid='.$guid;
|
||||
SendPasswordForgottenEmail::dispatch($ret, $resetLink);
|
||||
|
||||
return view('auth.passwords.email')->with('status', 'Password reset email has been sent!');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user