Force / respect password requirements set in site configuration when suggesting passwords

This commit is contained in:
nathan 2022-12-06 14:32:14 -07:00
parent 4001b3c67f
commit c0d4875422

View File

@ -125,7 +125,9 @@ class Password extends Etemplate\Widget\Textbox
*/ */
public static function ajax_suggest($size = 12) public static function ajax_suggest($size = 12)
{ {
$password = Auth::randomstring($size, false); $config = Api\Config::read('phpgwapi');
$size = max(min((int)$size, (int)$config['force_pwd_length']), 6);
$password = Auth::randomstring($size, $config['force_pwd_strength'] == 4);
$response = \EGroupware\Api\Json\Response::get(); $response = \EGroupware\Api\Json\Response::get();
$response->data($password); $response->data($password);