From e9710bdb76787ef32675740fbc162e28e5ea6abe Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 26 Dec 2022 05:47:20 +0000 Subject: [PATCH] formatting fix --- app/controllers/api/account.php | 16 ++++++++++------ app/controllers/api/users.php | 16 ++++++++++------ .../Projects/ProjectsConsoleClientTest.php | 2 +- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 2b7877b640..7a2d268d78 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -99,10 +99,12 @@ App::post('/v1/account') } } - if(str_contains($passwordsDB, $password)) { - throw new Exception(Exception::USER_PASSWORD_IN_DICTIONARY, + if (str_contains($passwordsDB, $password)) { + throw new Exception( + Exception::USER_PASSWORD_IN_DICTIONARY, 'The password is among the common passwords in dictionary.', - 403); + 403 + ); } $passwordHistory = $project->getAttribute('auths', [])['passwordHistory'] ?? 0; @@ -1533,10 +1535,12 @@ App::patch('/v1/account/password') throw new Exception(Exception::USER_INVALID_CREDENTIALS); } - if(str_contains($passwordsDB, $password)) { - throw new Exception(Exception::USER_PASSWORD_IN_DICTIONARY, + if (str_contains($passwordsDB, $password)) { + throw new Exception( + Exception::USER_PASSWORD_IN_DICTIONARY, 'The password is among the common passwords in dictionary.', - 403); + 403 + ); } $newPassword = Auth::passwordHash($password, Auth::DEFAULT_ALGO, Auth::DEFAULT_ALGO_OPTIONS); diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 2b8ed631b2..b087237422 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -114,10 +114,12 @@ App::post('/v1/users') ->inject('events') ->action(function (string $userId, ?string $email, ?string $phone, ?string $password, string $name, string $passwordsDB, Response $response, Document $project, Database $dbForProject, Event $events) { - if(str_contains($passwordsDB, $password)) { - throw new Exception(Exception::USER_PASSWORD_IN_DICTIONARY, + if (str_contains($passwordsDB, $password)) { + throw new Exception( + Exception::USER_PASSWORD_IN_DICTIONARY, 'The password is among the common passwords in dictionary.', - 403); + 403 + ); } $user = createUser('plaintext', '{}', $userId, $email, $password, $phone, $name, $project, $dbForProject, $events); @@ -813,10 +815,12 @@ App::patch('/v1/users/:userId/password') throw new Exception(Exception::USER_NOT_FOUND); } - if(str_contains($passwordsDB, $password)) { - throw new Exception(Exception::USER_PASSWORD_IN_DICTIONARY, + if (str_contains($passwordsDB, $password)) { + throw new Exception( + Exception::USER_PASSWORD_IN_DICTIONARY, 'The password is among the common passwords in dictionary.', - 403); + 403 + ); } $newPassword = Auth::passwordHash($password, Auth::DEFAULT_ALGO, Auth::DEFAULT_ALGO_OPTIONS); diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index 573b7b99f8..a7ca0cc86e 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -1174,7 +1174,7 @@ class ProjectsConsoleClientTest extends Scope ]); $this->assertEquals(403, $response['headers']['status-code']); - + /** * Create user */