Twofactor authentication and strong password

This commit is contained in:
2025-10-17 14:52:45 +02:00
parent 71a688f97f
commit dbd8c8aed2
17 changed files with 3055 additions and 14 deletions
+59
View File
@@ -304,3 +304,62 @@ function unique_multidim_array( $array, $key )
return $temp_array;
}
/**
* Validate password strength
* Password must contain:
* - At least 8 characters
* - At least 1 uppercase letter
* - At least 1 lowercase letter
* - At least 1 number
* - At least 1 special character
*
* @param string $password The password to validate
* @return bool True if password meets all requirements
*/
if ( ! function_exists( 'validate_password_strength' ) )
{
function validate_password_strength( $password )
{
if ( strlen( $password ) < 8 ) {
return FALSE;
}
if ( ! preg_match( '/[A-Z]/', $password ) ) {
return FALSE;
}
if ( ! preg_match( '/[a-z]/', $password ) ) {
return FALSE;
}
if ( ! preg_match( '/[0-9]/', $password ) ) {
return FALSE;
}
if ( ! preg_match( '/[^A-Za-z0-9]/', $password ) ) {
return FALSE;
}
return TRUE;
}
}
/**
* Get password validation requirements in Dutch
*
* @return array Array of password requirements
*/
if ( ! function_exists( 'get_password_requirements_nl' ) )
{
function get_password_requirements_nl()
{
return [
'Minimaal 8 karakters',
'Minimaal 1 hoofdletter',
'Minimaal 1 kleine letter',
'Minimaal 1 cijfer',
'Minimaal 1 speciaal teken (!@#$%^&* etc.)'
];
}
}