check email/username syntax before sending it to db
All checks were successful
mapguesser/pipeline/pr-develop This commit looks good

This commit is contained in:
Bence Pőcze 2023-09-26 00:43:14 +02:00
parent 2177dfd893
commit 0a7d248a3e
Signed by: bence
GPG Key ID: DC5BD6E95A333E6D

View File

@ -157,6 +157,13 @@ class LoginController
return new JsonContent(['success' => true]); return new JsonContent(['success' => true]);
} }
if (
filter_var(\Container::$request->post('email'), FILTER_VALIDATE_EMAIL) === false &&
preg_match('/^[a-zA-Z0-9_\-\.]+$/', \Container::$request->post('email')) !== 1
) {
return new JsonContent(['error' => ['errorText' => 'This is not a valid email address or username.']]);
}
$user = $this->userRepository->getByEmailOrUsername(\Container::$request->post('email')); $user = $this->userRepository->getByEmailOrUsername(\Container::$request->post('email'));
if ($user === null) { if ($user === null) {
@ -500,6 +507,13 @@ class LoginController
} }
} }
if (
filter_var(\Container::$request->post('email'), FILTER_VALIDATE_EMAIL) === false &&
preg_match('/^[a-zA-Z0-9_\-\.]+$/', \Container::$request->post('email')) !== 1
) {
return new JsonContent(['error' => ['errorText' => 'This is not a valid email address or username.']]);
}
$user = $this->userRepository->getByEmailOrUsername(\Container::$request->post('email')); $user = $this->userRepository->getByEmailOrUsername(\Container::$request->post('email'));
if ($user === null) { if ($user === null) {