refactor: fix formatting issues
This commit is contained in:
parent
6612e6edf0
commit
4abc30eed1
4 changed files with 15 additions and 17 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1060,7 +1060,7 @@ class ProjectsConsoleClientTest extends Scope
|
||||||
|
|
||||||
$this->assertEquals(409, $response['headers']['status-code']);
|
$this->assertEquals(409, $response['headers']['status-code']);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset
|
* Reset
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue