diff --git a/conf/accounts.conf b/conf/accounts.conf index f06b110..04f4304 100644 --- a/conf/accounts.conf +++ b/conf/accounts.conf @@ -29,6 +29,13 @@ define("GENERATED_PASSWORD_CHARACTERS", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklm */ define("GENERATED_PASSWORD_LENGTH", 8); +/* + * The default algorithm to use if not specified in the request + * + * Default value: MD5 + */ +define("DEFAULT_ALGORITHM", "MD5"); + /* * If set to True, a created account will automatically be activated and it's expiration date set to now + TRIAL_DURATION_DAYS, * otherwise expiration date for trial will be set when account is activated via a different xml rpc call. diff --git a/src/misc/utilities.php b/src/misc/utilities.php index 3e0553b..5a1792a 100644 --- a/src/misc/utilities.php +++ b/src/misc/utilities.php @@ -67,8 +67,8 @@ function check_parameter($param, $param_name = "username") { function get_algo($algo) { if ($algo == NULL || $algo == "") { - Logger::getInstance()->warning("Algo parameter wasn't found, assume MD5"); - return "MD5"; + Logger::getInstance()->warning("Algo parameter wasn't found, assume " . DEFAULT_ALGORITHM); + return DEFAULT_ALGORITHM; } if ($algo == "MD5" || $algo == "SHA-256" || $algo == "clrtxt") { return $algo; @@ -100,7 +100,8 @@ function get_lang($param) { function hash_password($user, $password, $domain, $algo) { $hashed_password = $password; if ($algo == "" || $algo == "MD5") $hashed_password = hash("md5", $user . ":" . $domain . ":" . $password); - if ($algo == "SHA-256") $hashed_password = hash("sha256", $user . ":" . $domain . ":" . $password); + else if ($algo == "SHA-256") $hashed_password = hash("sha256", $user . ":" . $domain . ":" . $password); + else Logger::getInstance()->error("Algorithm not supported: " . $algo); return $hashed_password; }