News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Server Side Password Validation RegEx - (Joomla 3.4.1, Virtuemart 3.0.9)

Started by kaiserdom, June 15, 2015, 18:50:07 PM

Previous topic - Next topic

kaiserdom

Joomla 3.4.1, Virtuemart 3.0.9
I had been trying to apply Server-Side Password Validation for a couple of months without the desired result, until I finally found the solution. For the validation I use a RegEx that meets my criteria. Password between 8 and 20 characters; must contain at least one lowercase letter, one uppercase letter, one numeric digit, and one special character, but cannot contain whitespace:
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9])(?!.*\s).{8,20}$

Given that, I added the green-colored code that follows, into the line 608 of the file mysite/libraries/joomla/user/user.php (just above the code in red color):


$match = "/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9])(?!.*\s).{8,20}$/";
if ( !(preg_match($match,$array['password'])) ) {
  JFactory::getApplication()->enqueueMessage(JText::_('JLIB_USER_ERROR_PASSWORD_TYPE_MATCH'),'error');
                 return false;
}


if (isset($array['password2']) && $array['password'] != $array['password2'])
{
     JFactory::getApplication()->enqueueMessage(JText::_('JLIB_USER_ERROR_PASSWORD_NOT_MATCH'), 'error');
            return false;
}



I also added (in any line you like or just add it to the end) into the file mySite/language/en-GB.lib_joomla.ini the row below :
JLIB_USER_ERROR_PASSWORD_TYPE_MATCH="Wrong Password Pattern. Please re-enter password."

That's it!
Server-Side validation  ;D