[英]Joomla 1.5 password check
我继承了一个joomla 1.5站点,该站点具有无法正常运行的重置密码组件。 ATM我可以将密码重设发送给用户输入的电子邮件,但是该组件缺少用于检查现有用户以查看电子邮件是否有效的功能。 我对PHP相当陌生,因此我不确定100%如何引入其他if语句。
到目前为止的样子:
public function submitemail() {
$db = JFactory::getDBO() ;
$requestedEmail = JRequest::getVar('emailaddr' , '') ;
$db->setQuery('select id , username, name, email from #__users where block = 0 and email = "'.$requestedEmail.'"') ;
if( $user = $db->loadObject() ) {
// Make sure the user isn't a Super Admin.
$juser = JFactory::getUser($user->id) ;
//joomla 1.6 and 1.5 check
if ($juser->authorize('core.admin') || $juser->usertype == 'Super Administrator') {
$this->setRedirect( 'index.php?option=com_resetpassword' , 'Email is not valid' ) ;
}
else {
$result = $this->sendPasswordResetEmail( $user ) ;
$this->setRedirect( 'index.php?option=com_resetpassword&layout=success' //, 'Please check your email and follow the instructions to reset your password '
) ;
}
}
else {
$this->setRedirect( 'index.php?option=com_resetpassword' );
}
}
我偶然发现了一个相关的文章片段。 我该如何检查用户输入的电子邮件中是否存在用于重置的数据库中当前存在的电子邮件地址?
function validate()
{ jimport('joomla.mail.helper');
$valid = true;
if ($this->_data->email && !JMailHelper::isEmailAddress($this->_data->email))
{
$this->_app->enqueueMessage(JText::_('Invalid Email Address'),'error');
$valid = false;
}
return $valid;
}
实际上,这正是它已经在做的事情。 顶部根据提交的电子邮件地址为用户加载行:
$requestedEmail = JRequest::getVar('emailaddr' , '') ;
$db->setQuery('select id , username, name, email from #__users where block = 0 and email = "'.$requestedEmail.'"') ;
if( $user = $db->loadObject() ) {
...
您可能需要做的就是将失败时的消息添加到底部的else语句中:
else {
$this->_app->enqueueMessage(JText::_('Invalid Email Address'),'error');
$this->setRedirect( 'index.php?option=com_resetpassword' );
}
如果未设置$this->_app
,则应改为使用以下代码:
JFactory::getApplication()->enqueueMessage(JText::_('Invalid Email Address'),'error');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.