|
|
|
|
@ -14,7 +14,7 @@ class UserManagement implements WorkflowInterface
|
|
|
|
|
{
|
|
|
|
|
public function __construct(
|
|
|
|
|
private PersistenceInterface $db,
|
|
|
|
|
private RequestInterface $ri,
|
|
|
|
|
private RequestInterface $request,
|
|
|
|
|
private AntiCSRFInterface $csrf,
|
|
|
|
|
private SessionInterface $session,
|
|
|
|
|
private mixed $userIndex,
|
|
|
|
|
@ -78,10 +78,7 @@ class UserManagement implements WorkflowInterface
|
|
|
|
|
{
|
|
|
|
|
$this->viewEnrollForm();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$this->viewUnenrollForm();
|
|
|
|
|
}
|
|
|
|
|
$this->viewUnenrollForm();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function response(): bool
|
|
|
|
|
@ -91,25 +88,25 @@ class UserManagement implements WorkflowInterface
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$p_uri = $this->db->getSecret($this->userIndex);
|
|
|
|
|
$enroll_flag = \is_null($p_uri);
|
|
|
|
|
$enroll_flag && $enroll_flag = $this->session->get('secret');
|
|
|
|
|
$pUri = $this->db->getSecret($this->userIndex);
|
|
|
|
|
$enrollFlag = \is_null($pUri);
|
|
|
|
|
$enrollFlag && $enrollFlag = $this->session->get('secret');
|
|
|
|
|
|
|
|
|
|
$totp = _6238(
|
|
|
|
|
$p_uri.secret,
|
|
|
|
|
$p_uri.period,
|
|
|
|
|
$enroll_flag? 0:$this->db->getLastTime($this->userIndex),
|
|
|
|
|
$pUri.secret,
|
|
|
|
|
$pUri.period,
|
|
|
|
|
$enrollFlag? 0:$this->db->getLastTime($this->userIndex),
|
|
|
|
|
2,
|
|
|
|
|
$p_uri.digits,
|
|
|
|
|
$pUri.digits,
|
|
|
|
|
$this->clock,
|
|
|
|
|
$this->hash
|
|
|
|
|
);
|
|
|
|
|
$flag = $totp.validate($this->ri->getResp("totp_challenge"));
|
|
|
|
|
|
|
|
|
|
if($flag && $enroll_flag)
|
|
|
|
|
if($flag && $enrollFlag)
|
|
|
|
|
{
|
|
|
|
|
$this->db->storeLastTime($this->userIndex, $flag);
|
|
|
|
|
$this->db->storeSecret($this->userIndex, $p_uri);
|
|
|
|
|
$this->db->storeSecret($this->userIndex, $pUri);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else if($flag)
|
|
|
|
|
|