Skip to content
Snippets Groups Projects
Commit e6d7649c authored by Till Brehm's avatar Till Brehm
Browse files

Merge branch 'patch-min_password_length' into 'master'

Create a util function to remove duplication

See merge request ispconfig/ispconfig3!866
parents e5322cbb 6d8d6168
No related branches found
No related tags found
No related merge requests found
......@@ -188,6 +188,36 @@ class auth {
}
/**
* Get the minimum password length.
*/
public function get_min_password_length() {
global $app;
$server_config_array = $app->getconf->get_global_config();
$min_password_length = 8;
if(isset($server_config_array['misc']['min_password_length'])) $min_password_length = $server_config_array['misc']['min_password_length'];
return $min_password_length;
}
/**
* Get the minimum password strength.
*/
public function get_min_password_strength() {
global $app;
$server_config_array = $app->getconf->get_global_config();
$min_password_strength = 0;
if(isset($server_config_array['misc']['min_password_strength'])) $min_password_strength = $server_config_array['misc']['min_password_strength'];;
return $min_password_strength;
}
/**
* Generate a ranmdom password.
*
* @param int $minLength
* Minimum number of characters.
* @param boolean $special
* Include special characters, like # and !
*/
public function get_random_password($minLength = 8, $special = false) {
if($minLength < 8) $minLength = 8;
$maxLength = $minLength + 5;
......
......@@ -111,10 +111,8 @@ class validate_password {
$app->uses('ini_parser,getconf');
$server_config_array = $app->getconf->get_global_config();
$min_password_strength = 0;
$min_password_length = 5;
if(isset($server_config_array['misc']['min_password_length'])) $min_password_length = $server_config_array['misc']['min_password_length'];
if(isset($server_config_array['misc']['min_password_strength'])) $min_password_strength = $server_config_array['misc']['min_password_strength'];
$min_password_length = $app->auth->get_min_password_length();
$min_password_strength = $app->auth->get_min_password_strength();
if($min_password_strength > 0) {
$lng_text = $app->lng('weak_password_txt');
......
......@@ -123,8 +123,7 @@ if(isset($_POST['username']) && $_POST['username'] != '' && $_POST['email'] != '
} elseif ($continue) {
if($client['client_id'] > 0) {
$server_config_array = $app->getconf->get_global_config();
$min_password_length = 8;
if(isset($server_config_array['misc']['min_password_length'])) $min_password_length = $server_config_array['misc']['min_password_length'];
$min_password_length = $app->auth->get_min_password_length();
$new_password = $app->auth->get_random_password($min_password_length, true);
$new_password_encrypted = $app->auth->crypt_password($new_password);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment