diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 078d3ce0ce..02a05e7d92 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -97,7 +97,7 @@ App::post('/v1/account') } } - $passwordHistory = $project->getAttribute('auths',[])['passwordHistory'] ?? 0; + $passwordHistory = $project->getAttribute('auths', [])['passwordHistory'] ?? 0; $password = Auth::passwordHash($password, Auth::DEFAULT_ALGO, Auth::DEFAULT_ALGO_OPTIONS); try { @@ -493,7 +493,7 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') } } - $passwordHistory = $project->getAttribute('auths',[])['passwordHistory'] ?? 0; + $passwordHistory = $project->getAttribute('auths', [])['passwordHistory'] ?? 0; try { $userId = ID::unique(); @@ -1528,18 +1528,17 @@ App::patch('/v1/account/password') $historyLimit = $project->getAttribute('auths', [])['passwordHistory'] ?? 0; $history = []; - if($historyLimit > 0) { + if ($historyLimit > 0) { $history = $user->getAttribute('passwordHistory', []); - - foreach($history as $hash) { - if(Auth::passwordVerify($password, $hash, $user->getAttribute('hash'), $user->getAttribute('hashOptions'))) - { + + foreach ($history as $hash) { + if (Auth::passwordVerify($password, $hash, $user->getAttribute('hash'), $user->getAttribute('hashOptions'))) { throw new Exception(Exception::USER_PASSWORD_RECENTLY_USED, 'The password was recently used', 409); } } $history[] = $newPassword; - while(count($history) > $historyLimit) { + while (count($history) > $historyLimit) { array_pop($history); } } diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 5934ec9c4c..7775346a8a 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -345,7 +345,7 @@ App::post('/v1/teams/:teamId/memberships') } } - $passwordHistory = $project->getAttribute('auths',[])['passwordHistory'] ?? 0; + $passwordHistory = $project->getAttribute('auths', [])['passwordHistory'] ?? 0; try { $userId = ID::unique(); diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 65d31d8d3b..bcfe5575c8 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -804,21 +804,20 @@ App::patch('/v1/users/:userId/password') } $newPassword = Auth::passwordHash($password, Auth::DEFAULT_ALGO, Auth::DEFAULT_ALGO_OPTIONS); - + $historyLimit = $project->getAttribute('auths', [])['passwordHistory'] ?? 0; $history = []; - if($historyLimit > 0) { + if ($historyLimit > 0) { $history = $user->getAttribute('passwordHistory', []); - - foreach($history as $hash) { - if(Auth::passwordVerify($password, $hash, $user->getAttribute('hash'), $user->getAttribute('hashOptions'))) - { + + foreach ($history as $hash) { + if (Auth::passwordVerify($password, $hash, $user->getAttribute('hash'), $user->getAttribute('hashOptions'))) { throw new Exception(Exception::USER_PASSWORD_RECENTLY_USED, 'The password was recently used', 409); } } $history[] = $newPassword; - while(count($history) > $historyLimit) { + while (count($history) > $historyLimit) { array_pop($history); } } diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index 504643f61f..ff49739976 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -1060,7 +1060,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(409, $response['headers']['status-code']); - + /** * Reset */