1
0
Fork 0
mirror of synced 2024-06-28 19:20:25 +12: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);
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);
}
}

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 {
$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);
$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);
}
}

View file

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