Skip to content

Commit

Permalink
fixup! feat: Use inline password confirmation in external storage set…
Browse files Browse the repository at this point in the history
…tings
  • Loading branch information
artonge committed Nov 28, 2024
1 parent 44f94f3 commit 6e2110a
Showing 1 changed file with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,21 @@ public function beforeController(Controller $controller, string $methodName) {
return;
}

$lastConfirm = (int) $this->session->get('last-password-confirm');
// TODO: confirm excludedUserBackEnds can go away and remove it
if (!isset($this->excludedUserBackEnds[$backendClassName]) && $lastConfirm < ($this->timeFactory->getTime() - (30 * 60 + 15))) { // allow 15 seconds delay
throw new NotConfirmedException();
if ($this->isPasswordConfirmationStrict($reflectionMethod)) {
$authHeader = $this->request->getHeader('Authorization');
[, $password] = explode(':', base64_decode(substr($authHeader, 6)), 2);
$loginResult = $this->userManager->checkPassword($user->getUid(), $password);
if ($loginResult === false) {
throw new NotConfirmedException();
}

$this->session->set('last-password-confirm', $this->timeFactory->getTime());
} else {
$lastConfirm = (int) $this->session->get('last-password-confirm');
// TODO: confirm excludedUserBackEnds can go away and remove it
if (!isset($this->excludedUserBackEnds[$backendClassName]) && $lastConfirm < ($this->timeFactory->getTime() - (30 * 60 + 15))) { // allow 15 seconds delay
throw new NotConfirmedException();
}
}
}
}
Expand All @@ -113,7 +124,7 @@ private function needsPasswordConfirmation(ReflectionMethod $reflectionMethod):
return true;
}

if ($this->reflector->hasAnnotation($annotationName)) {
if ($this->reflector->hasAnnotation('PasswordConfirmationRequired')) {
return true;
}

Expand Down

0 comments on commit 6e2110a

Please sign in to comment.