feat: address review comments

This commit is contained in:
Christy Jacob
2024-07-22 12:55:15 +04:00
parent 98b8e13add
commit 7614a356a2
2 changed files with 8 additions and 8 deletions
+6 -6
View File
@@ -876,12 +876,6 @@ App::patch('/v1/projects/:projectId/auth/mock-numbers')
->inject('dbForConsole')
->action(function (string $projectId, array $numbers, Response $response, Database $dbForConsole) {
$project = $dbForConsole->getDocument('projects', $projectId);
if ($project->isEmpty()) {
throw new Exception(Exception::PROJECT_NOT_FOUND);
}
$uniqueNumbers = [];
foreach ($numbers as $number) {
if (isset($uniqueNumbers[$number['phone']])) {
@@ -889,6 +883,12 @@ App::patch('/v1/projects/:projectId/auth/mock-numbers')
}
$uniqueNumbers[$number['phone']] = $number['otp'];
}
$project = $dbForConsole->getDocument('projects', $projectId);
if ($project->isEmpty()) {
throw new Exception(Exception::PROJECT_NOT_FOUND);
}
$auths = $project->getAttribute('auths', []);
+2 -2
View File
@@ -46,8 +46,8 @@ class MockNumber extends Validator
return false;
}
$otp = new Text(6, 6);
if (!$otp->isValid($value['otp']) || !\ctype_digit($value['otp'])) {
$otp = new Text(6, 6, Text::NUMBERS);
if (!$otp->isValid($value['otp'])) {
$this->message = 'Invalid OTP. Please make sure the OTP is a 6 digit number';
return false;
}