#11430 Added a validation that checks if the User id already exists
This commit is contained in:
parent
a1ca1a95fd
commit
162c33733f
|
@ -384,6 +384,8 @@ if ($create_user === true) {
|
|||
|
||||
// Generate new API token.
|
||||
$values['api_token'] = api_token_generate();
|
||||
// Validate the user ID if it already exists.
|
||||
$user_exists = get_user_info($id);
|
||||
|
||||
if (empty($id) === true) {
|
||||
ui_print_error_message(__('User ID cannot be empty'));
|
||||
|
@ -392,6 +394,13 @@ if ($create_user === true) {
|
|||
$password_new = '';
|
||||
$password_confirm = '';
|
||||
$new_user = true;
|
||||
} else if (isset($user_exists['id_user'])) {
|
||||
$is_err = true;
|
||||
ui_print_error_message(__('User ID already exists'));
|
||||
$user_info = $values;
|
||||
$password_new = '';
|
||||
$password_confirm = '';
|
||||
$new_user = true;
|
||||
} else if (preg_match('/^\s+|\s+$/', io_safe_output($id))) {
|
||||
ui_print_error_message(__('Invalid user ID: leading or trailing blank spaces not allowed'));
|
||||
$is_err = true;
|
||||
|
|
Loading…
Reference in New Issue