diff --git a/src/app/user/controllers/UserController.php b/src/app/user/controllers/UserController.php index 8b8b2cbbe81b85fac8befd75f21738ff2be0a9c5..6b1c99760fe4fe189bbb576c89fb9ce856c3e525 100755 --- a/src/app/user/controllers/UserController.php +++ b/src/app/user/controllers/UserController.php @@ -165,11 +165,11 @@ class UserController $check = Validator::stringType()->length(1, 128)->notEmpty()->validate($data['userId']) && preg_match("/^[\w.@-]*$/", $data['userId']); $check = $check && Validator::stringType()->length(1, 255)->notEmpty()->validate($data['firstname']); $check = $check && Validator::stringType()->length(1, 255)->notEmpty()->validate($data['lastname']); - $check = $check && Validator::stringType()->length(0, 32)->notEmpty()->validate($data['initials']); + $check = $check && Validator::stringType()->length(0, 32)->validate($data['initials'] ?? ''); $check = $check && Validator::stringType()->length(1, 255)->notEmpty()->validate($data['mail']); $check = $check && (empty($data['mail']) || filter_var($data['mail'], FILTER_VALIDATE_EMAIL)); if (PrivilegeController::hasPrivilege(['privilegeId' => 'manage_personal_data', 'userId' => $GLOBALS['id']])) { - $check = $check && (empty($data['phone']) || preg_match("/\+?((|\ |\.|\(|\)|\-)?(\d)*)*\d$/", $data['phone'])) && Validator::stringType()->length(0, 32)->validate($data['phone']); + $check = $check && (empty($data['phone']) || preg_match("/\+?((|\ |\.|\(|\)|\-)?(\d)*)*\d$/", $data['phone'])) && Validator::stringType()->length(0, 32)->validate($data['phone'] ?? ''); } if (!$check) { return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); @@ -249,10 +249,10 @@ class UserController $check = Validator::stringType()->length(1, 255)->notEmpty()->validate($data['firstname']); $check = $check && Validator::stringType()->length(1, 255)->notEmpty()->validate($data['lastname']); - $check = $check && Validator::stringType()->length(0, 32)->validate($data['initials']); + $check = $check && Validator::stringType()->length(0, 32)->validate($data['initials'] ?? ''); $check = $check && (empty($data['mail']) || filter_var($data['mail'], FILTER_VALIDATE_EMAIL) && Validator::stringType()->length(1, 255)->notEmpty()->validate($data['mail'])); if (PrivilegeController::hasPrivilege(['privilegeId' => 'manage_personal_data', 'userId' => $GLOBALS['id']])) { - $check = $check && (empty($data['phone']) || preg_match("/\+?((|\ |\.|\(|\)|\-)?(\d)*)*\d$/", $data['phone'])) && Validator::stringType()->length(0, 32)->validate($data['phone']); + $check = $check && (empty($data['phone']) || preg_match("/\+?((|\ |\.|\(|\)|\-)?(\d)*)*\d$/", $data['phone'])) && Validator::stringType()->length(0, 32)->validate($data['phone'] ?? ''); } if (!$check) { return $response->withStatus(400)->withJson(['errors' => 'Bad Request']);