1
0
Fork 0
mirror of synced 2024-09-30 01:08:13 +13:00

refactor: fix formatting issues

This commit is contained in:
Damodar Lohani 2022-12-18 06:31:14 +00:00
parent 6612e6edf0
commit 4abc30eed1
4 changed files with 15 additions and 17 deletions

View file

@ -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); $password = Auth::passwordHash($password, Auth::DEFAULT_ALGO, Auth::DEFAULT_ALGO_OPTIONS);
try { 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 { try {
$userId = ID::unique(); $userId = ID::unique();
@ -1528,18 +1528,17 @@ App::patch('/v1/account/password')
$historyLimit = $project->getAttribute('auths', [])['passwordHistory'] ?? 0; $historyLimit = $project->getAttribute('auths', [])['passwordHistory'] ?? 0;
$history = []; $history = [];
if($historyLimit > 0) { if ($historyLimit > 0) {
$history = $user->getAttribute('passwordHistory', []); $history = $user->getAttribute('passwordHistory', []);
foreach($history as $hash) { foreach ($history as $hash) {
if(Auth::passwordVerify($password, $hash, $user->getAttribute('hash'), $user->getAttribute('hashOptions'))) 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); throw new Exception(Exception::USER_PASSWORD_RECENTLY_USED, 'The password was recently used', 409);
} }
} }
$history[] = $newPassword; $history[] = $newPassword;
while(count($history) > $historyLimit) { while (count($history) > $historyLimit) {
array_pop($history); array_pop($history);
} }
} }

View file

@ -345,7 +345,7 @@ App::post('/v1/teams/:teamId/memberships')
} }
} }
$passwordHistory = $project->getAttribute('auths',[])['passwordHistory'] ?? 0; $passwordHistory = $project->getAttribute('auths', [])['passwordHistory'] ?? 0;
try { try {
$userId = ID::unique(); $userId = ID::unique();

View file

@ -804,21 +804,20 @@ App::patch('/v1/users/:userId/password')
} }
$newPassword = Auth::passwordHash($password, Auth::DEFAULT_ALGO, Auth::DEFAULT_ALGO_OPTIONS); $newPassword = Auth::passwordHash($password, Auth::DEFAULT_ALGO, Auth::DEFAULT_ALGO_OPTIONS);
$historyLimit = $project->getAttribute('auths', [])['passwordHistory'] ?? 0; $historyLimit = $project->getAttribute('auths', [])['passwordHistory'] ?? 0;
$history = []; $history = [];
if($historyLimit > 0) { if ($historyLimit > 0) {
$history = $user->getAttribute('passwordHistory', []); $history = $user->getAttribute('passwordHistory', []);
foreach($history as $hash) { foreach ($history as $hash) {
if(Auth::passwordVerify($password, $hash, $user->getAttribute('hash'), $user->getAttribute('hashOptions'))) 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); throw new Exception(Exception::USER_PASSWORD_RECENTLY_USED, 'The password was recently used', 409);
} }
} }
$history[] = $newPassword; $history[] = $newPassword;
while(count($history) > $historyLimit) { while (count($history) > $historyLimit) {
array_pop($history); array_pop($history);
} }
} }

View file

@ -1060,7 +1060,7 @@ class ProjectsConsoleClientTest extends Scope
$this->assertEquals(409, $response['headers']['status-code']); $this->assertEquals(409, $response['headers']['status-code']);
/** /**
* Reset * Reset
*/ */