I'm trying to dismiss the login if my $completed
var is false.
I can make it work with die()
but I wan't to know how to do this correct, so that the user gets returned to the login page with a error message.
I've tried with return NULL;
, return false;
and just return;
I can't make it work or find the solution anywhere. I really hope you can help me out.
This is my code:
defined('_JEXEC') or die;
class plgAuthenticationTestlogin extends JPlugin{
function onUserAuthenticate( $credentials, $options, &$response ){
$captcha_plugin = JFactory::getConfig()->get('captcha');
$captcha = JCaptcha::getInstance($captcha_plugin);
$completed = $captcha->CheckAnswer('captcha');
if(!$completed){
$response->status = JAuthentication::STATUS_FAILURE;
$response->error_message = 'captcha not correct';
die("not valid reCaptcha");
}
}
}
It is placed inside a plugin made. placed inside the folder: plugins > authentication > mypluginFolder > myplugin.php
This plugin works fine as described above - The login is aborted if I use die("not valid reCaptcha");
->redirect()
comment before I deleted it). Inspired by, stackoverflow.com/q/24556095/2943403 Unfortunately, your updated question is now seeking a "Yes/No" response. Perhaps you should post your update as an answer, then if someone offers a better answer, you can upvote/accept the other. Until then, it looks like you have the answer that you can be happy with.user
directory inlibraries/joomla
. Perhaps the docs need to be updated.