From 1a61e960435e36401c21c99b6f90f97ad0344244 Mon Sep 17 00:00:00 2001 From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com> Date: Fri, 27 Jan 2023 12:11:08 +0100 Subject: [PATCH] Add password confirmation verification --- Controllers/UserController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Controllers/UserController.php b/Controllers/UserController.php index ec1126e..0fa1b3c 100644 --- a/Controllers/UserController.php +++ b/Controllers/UserController.php @@ -70,12 +70,15 @@ final class UserController $S_email = Utils::getOrDie($A_postParams, "email"); $S_username = Utils::getOrDie($A_postParams, "username"); $S_password = Utils::getOrDie($A_postParams, "password"); + $S_password_confirm = Utils::getOrDie($A_postParams, "password_confirm"); if (!filter_var($S_email, FILTER_VALIDATE_EMAIL)) { $S_errmsg = "invalid email"; } else if( strlen($S_password) < 8 || strlen($S_password) > 150 ) { $S_errmsg = "password must be between 8 and 150 characters"; + } else if( $S_password !== $S_password_confirm) { + $S_errmsg = "password confirmation do not match"; } else if(UserModel::isEmailInDatabase($S_email)) { $S_errmsg = "An user with this email is already registered"; }