diff --git a/Changelog b/Changelog index c1348596c..917e99e41 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2018-05-04 DariusIII + * Fix: Fix nocaptcha display on login, contact, forgottenpassword and register pages * Chg: Remove stray column from getmoviesRange function * Chg: Remove main, usefull and article menus from basepage controller * Chg: Update utils-admin.js with tinymce diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index fc2175f70..19b8e279c 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -6,6 +6,7 @@ use App\Models\User; use App\Models\Settings; use App\Mail\ForgottenPassword; use App\Http\Controllers\Controller; +use Illuminate\Http\Request; use Illuminate\Support\Facades\Mail; use Illuminate\Foundation\Auth\SendsPasswordResetEmails; @@ -34,7 +35,7 @@ class ForgotPasswordController extends Controller $this->middleware('guest'); } - public function showLinkRequestForm() + public function showLinkRequestForm(Request $request) { $sent = ''; $email = request()->input('email') ?? ''; @@ -42,6 +43,11 @@ class ForgotPasswordController extends Controller if (empty($email) && empty($rssToken)) { app('smarty.view')->assign('error', 'Missing parameter(email and/or apikey to send password reset'); } else { + if (env('NOCAPTCHA_ENABLED') === true && (!empty(env('NOCAPTCHA_SECRET')) && ! empty(env('NOCAPTCHA_SITEKEY')))) { + $this->validate($request, [ + 'g-recaptcha-response' => 'required|captcha', + ]); + } // // Check users exists and send an email // @@ -58,7 +64,7 @@ class ForgotPasswordController extends Controller // // Send the email // - $resetLink = request()->server('SERVER_NAME').'/forgottenpassword?action=reset&guid='.$guid; + $resetLink = $request->server('SERVER_NAME').'/forgottenpassword?action=reset&guid='.$guid; Mail::to($ret['email'])->send(new ForgottenPassword($resetLink)); $sent = true; } diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 001f56cac..0b66088f1 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -51,7 +51,7 @@ class LoginController extends Controller 'password' => 'required', ]); - if (env('NOCAPTCHA_ENABLED') === true) { + if (env('NOCAPTCHA_ENABLED') === true && (!empty(env('NOCAPTCHA_SECRET')) && ! empty(env('NOCAPTCHA_SITEKEY')))) { $this->validate($request, [ 'g-recaptcha-response' => 'required|captcha', ]); @@ -85,7 +85,6 @@ class LoginController extends Controller { $theme = Settings::settingValue('site.main.style'); app('smarty.view')->assign(['error' => '', 'username' => '', 'rememberme' => '']); - $nocaptcha = env('NOCAPTCHA_ENABLED'); $meta_title = 'Login'; $meta_keywords = 'Login'; @@ -94,7 +93,6 @@ class LoginController extends Controller app('smarty.view')->assign( [ 'error' => 'These credentials do not match our records.', - 'nocaptcha'=> $nocaptcha, 'content' => $content, 'meta_title' => $meta_title, 'meta_keywords' => $meta_keywords, diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index eeaacef25..1a8b94fb9 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -82,7 +82,7 @@ class RegisterController extends Controller 'password' => 'required|string|min:8|confirmed', ]); - if (env('NOCAPTCHA_ENABLED') === true) { + if (env('NOCAPTCHA_ENABLED') === true && (!empty(env('NOCAPTCHA_SECRET')) && ! empty(env('NOCAPTCHA_SITEKEY')))) { $this->validate($request, [ 'g-recaptcha-response' => 'required|captcha', ]); diff --git a/app/Http/Controllers/BasePageController.php b/app/Http/Controllers/BasePageController.php index 64b65f346..96de882db 100644 --- a/app/Http/Controllers/BasePageController.php +++ b/app/Http/Controllers/BasePageController.php @@ -92,7 +92,7 @@ class BasePageController extends Controller * * @throws \Exception */ - public function __construct(Request $request) + public function __construct() { $this->middleware('auth')->except('api', 'rss', 'contact', 'showContactForm', 'callback'); // Buffer settings/DB connection. diff --git a/app/Http/Controllers/ContactUsController.php b/app/Http/Controllers/ContactUsController.php index 21fe6a5f4..cf79efecc 100644 --- a/app/Http/Controllers/ContactUsController.php +++ b/app/Http/Controllers/ContactUsController.php @@ -17,13 +17,12 @@ class ContactUsController extends BasePageController */ public function contact(Request $request) { - $this->setPrefs(); $this->validate($request, [ 'useremail' => 'required', 'username' => 'required', ]); - if (env('NOCAPTCHA_ENABLED') === true) { + if (env('NOCAPTCHA_ENABLED') === true && (!empty(env('NOCAPTCHA_SECRET')) && ! empty(env('NOCAPTCHA_SITEKEY')))) { $this->validate($request, [ 'g-recaptcha-response' => 'required|captcha', ]); @@ -47,7 +46,7 @@ class ContactUsController extends BasePageController } $msg = "
- {NoCaptcha::display()}{NoCaptcha::renderJs()} + {if {env('NOCAPTCHA_ENABLED')} == 1 && !empty({env('NOCAPTCHA_SITEKEY')}) && !empty({env('NOCAPTCHA_SECRET')})} + {NoCaptcha::display()}{NoCaptcha::renderJs()} + {/if}
diff --git a/resources/views/themes/Charisma/login.tpl b/resources/views/themes/Charisma/login.tpl index feeaf2627..0d29ec4de 100755 --- a/resources/views/themes/Charisma/login.tpl +++ b/resources/views/themes/Charisma/login.tpl @@ -67,7 +67,7 @@
- {if $nocaptcha != false} + {if {env('NOCAPTCHA_ENABLED')} == 1 && !empty({env('NOCAPTCHA_SITEKEY')}) && !empty({env('NOCAPTCHA_SECRET')})} {NoCaptcha::display()}{NoCaptcha::renderJs()} {/if}
diff --git a/resources/views/themes/Charisma/register.tpl b/resources/views/themes/Charisma/register.tpl index b82803f00..d75bd6e6a 100755 --- a/resources/views/themes/Charisma/register.tpl +++ b/resources/views/themes/Charisma/register.tpl @@ -72,7 +72,7 @@
- {if $nocaptcha != false} + {if {env('NOCAPTCHA_ENABLED')} == 1 && !empty({env('NOCAPTCHA_SITEKEY')}) && !empty({env('NOCAPTCHA_SECRET')})} {NoCaptcha::display()}{NoCaptcha::renderJs()} {/if}
diff --git a/resources/views/themes/Gentele/contact.tpl b/resources/views/themes/Gentele/contact.tpl index f16702979..f678b7c21 100755 --- a/resources/views/themes/Gentele/contact.tpl +++ b/resources/views/themes/Gentele/contact.tpl @@ -54,7 +54,7 @@ - {if $nocaptcha != false} + {if {env('NOCAPTCHA_ENABLED')} == 1 && !empty({env('NOCAPTCHA_SITEKEY')}) && !empty({env('NOCAPTCHA_SECRET')})} {NoCaptcha::display()}{NoCaptcha::renderJs()} {/if}