简体   繁体   English

Joomla管理登录自定义错误

[英]Joomla Administration Login Custom Error

I'm using Google reCAPTCHA on joomla admini login section, Validation works fine. 我在joomla管理员登录部分上使用了Google reCAPTCHA,验证工作正常。

Captcha validation added to administrator/components/com_login/models/login.php 验证码验证已添加到administrator/components/com_login/models/login.php

 $privatekey = "myprivatekey";
 $resp = recaptcha_check_answer (
        $privatekey,
        $_SERVER["REMOTE_ADDR"],
        JRequest::getVar('recaptcha_challenge_field', '', 'method', 'recaptcha_challenge_field'),
        JRequest::getVar('recaptcha_response_field', '', 'method', 'recaptcha_response_field')
    );

 if (!$resp->is_valid) {
    //die('Incorrect Captcha...');
 }else{     
    $credentials = array(
        'username' => JRequest::getVar('username', '', 'method', 'username'),
        'password' => JRequest::getVar('passwd', '', 'post', 'string', JREQUEST_ALLOWRAW)
    );
    $this->setState('credentials', $credentials);
 }

What should I use instead of //die('Incorrect Captcha...'); 我应该用什么代替//die('Incorrect Captcha...'); to output Invalid Captcha! 输出无效的验证码! Error in login page? 登录页面错误?

错误样本图片

Try this- 尝试这个-

$app = JFactory::getApplication();
$app->enqueueMessage('Incorrect Captcha...', 'error');
$app->redirect(JURI::base());

You can use JError to show the error when the output in invalid. 当输出无效时,可以使用JError显示错误。

For example: 例如:

JError::raiseError( JText::_( 'Invalid Captcha' ));

For more methods you can see this JError 有关更多方法,您可以看到此JError

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM