type fixes
This commit is contained in:
@@ -43,6 +43,8 @@ use Espo\Core\Authentication\Result\FailReason;
|
||||
|
||||
use Espo\Core\Api\Request;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class EmailLogin implements Login
|
||||
{
|
||||
/**
|
||||
@@ -62,13 +64,23 @@ class EmailLogin implements Login
|
||||
{
|
||||
$code = $request->getHeader('Espo-Authorization-Code');
|
||||
|
||||
if (!$code) {
|
||||
$this->util->sendCode($result->getLoggedUser());
|
||||
$loggedUser = $result->getLoggedUser();
|
||||
|
||||
return Result::secondStepRequired($result->getUser(), $this->getResultData());
|
||||
if (!$loggedUser) {
|
||||
throw new RuntimeException("No logged-user.");
|
||||
}
|
||||
|
||||
$loggedUser = $result->getLoggedUser();
|
||||
if (!$code) {
|
||||
$user = $result->getUser();
|
||||
|
||||
if (!$user) {
|
||||
throw new RuntimeException("No user.");
|
||||
}
|
||||
|
||||
$this->util->sendCode($loggedUser);
|
||||
|
||||
return Result::secondStepRequired($user, $this->getResultData());
|
||||
}
|
||||
|
||||
if ($this->verifyCode($loggedUser, $code)) {
|
||||
return $result;
|
||||
|
||||
@@ -115,6 +115,10 @@ class Util
|
||||
|
||||
$userData = $this->getUserDataRepository()->getByUserId($user->getId());
|
||||
|
||||
if (!$userData) {
|
||||
throw new Error("UserData not found.");
|
||||
}
|
||||
|
||||
$userData->set('auth2FAEmailAddress', $emailAddress);
|
||||
|
||||
$this->entityManager->saveEntity($userData);
|
||||
@@ -215,7 +219,8 @@ class Util
|
||||
throw new Error("User does not have email address.");
|
||||
}
|
||||
|
||||
return $user->getEmailAddressGroup()->getPrimary()->getAddress();
|
||||
/** @var string */
|
||||
return $user->getEmailAddressGroup()->getPrimaryAddress();
|
||||
}
|
||||
|
||||
private function checkEmailAddressIsUsers(User $user, string $emailAddress): void
|
||||
|
||||
@@ -42,6 +42,8 @@ use Espo\Core\Authentication\Result\Data as ResultData;
|
||||
use Espo\Core\Authentication\Result\FailReason;
|
||||
use Espo\Core\Api\Request;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class SmsLogin implements Login
|
||||
{
|
||||
/**
|
||||
@@ -61,13 +63,23 @@ class SmsLogin implements Login
|
||||
{
|
||||
$code = $request->getHeader('Espo-Authorization-Code');
|
||||
|
||||
if (!$code) {
|
||||
$this->util->sendCode($result->getLoggedUser());
|
||||
$loggedUser = $result->getLoggedUser();
|
||||
|
||||
return Result::secondStepRequired($result->getUser(), $this->getResultData());
|
||||
if (!$loggedUser) {
|
||||
throw new RuntimeException("No logged-user.");
|
||||
}
|
||||
|
||||
$loggedUser = $result->getLoggedUser();
|
||||
if (!$code) {
|
||||
$user = $result->getUser();
|
||||
|
||||
if (!$user) {
|
||||
throw new RuntimeException("No user.");
|
||||
}
|
||||
|
||||
$this->util->sendCode($loggedUser);
|
||||
|
||||
return Result::secondStepRequired($user, $this->getResultData());
|
||||
}
|
||||
|
||||
if ($this->verifyCode($loggedUser, $code)) {
|
||||
return $result;
|
||||
|
||||
@@ -110,6 +110,10 @@ class Util
|
||||
|
||||
$userData = $this->getUserDataRepository()->getByUserId($user->getId());
|
||||
|
||||
if (!$userData) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
$userData->set('auth2FASmsPhoneNumber', $phoneNumber);
|
||||
|
||||
$this->entityManager->saveEntity($userData);
|
||||
@@ -210,7 +214,8 @@ class Util
|
||||
throw new Error("User does not have phone number.");
|
||||
}
|
||||
|
||||
return $user->getPhoneNumberGroup()->getPrimary()->getNumber();
|
||||
/** @var string */
|
||||
return $user->getPhoneNumberGroup()->getPrimaryNumber();
|
||||
}
|
||||
|
||||
private function checkPhoneNumberIsUsers(User $user, string $phoneNumber): void
|
||||
|
||||
@@ -43,6 +43,8 @@ use Espo\Core\Authentication\Result\FailReason;
|
||||
|
||||
use Espo\Core\Api\Request;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class TotpLogin implements Login
|
||||
{
|
||||
/**
|
||||
@@ -63,11 +65,21 @@ class TotpLogin implements Login
|
||||
$code = $request->getHeader('Espo-Authorization-Code');
|
||||
|
||||
if (!$code) {
|
||||
return Result::secondStepRequired($result->getUser(), $this->getResultData());
|
||||
$user = $result->getUser();
|
||||
|
||||
if (!$user) {
|
||||
throw new RuntimeException("No user.");
|
||||
}
|
||||
|
||||
return Result::secondStepRequired($user, $this->getResultData());
|
||||
}
|
||||
|
||||
$loggedUser = $result->getLoggedUser();
|
||||
|
||||
if (!$loggedUser) {
|
||||
throw new RuntimeException("No logged-user.");
|
||||
}
|
||||
|
||||
if ($this->verifyCode($loggedUser, $code)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -103,6 +103,10 @@ class TotpUserSetup implements UserSetup
|
||||
{
|
||||
$userData = $this->getUserDataRepository()->getByUserId($user->getId());
|
||||
|
||||
if (!$userData) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
$userData->set('auth2FATotpSecret', $secret);
|
||||
|
||||
$this->entityManager->saveEntity($userData);
|
||||
|
||||
@@ -64,6 +64,7 @@ class BindingContainer
|
||||
throw new LogicException("BindingContainer: Can't get not existing binding.");
|
||||
}
|
||||
|
||||
/** @var Binding */
|
||||
return $this->getInternal($class, $param);
|
||||
}
|
||||
|
||||
@@ -82,7 +83,7 @@ class BindingContainer
|
||||
$key = '$' . $param->getName();
|
||||
}
|
||||
|
||||
if ($className && $this->data->hasContext($className, $key) && $key) {
|
||||
if ($className && $key && $this->data->hasContext($className, $key)) {
|
||||
return $this->data->getContext($className, $key);
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ class CommandManager
|
||||
throw new CommandNotFound("Command '" . Util::camelCaseToHyphen($command) ."' does not exist.");
|
||||
}
|
||||
|
||||
/** @var ?class-string<Command> */
|
||||
/** @var class-string<Command> */
|
||||
return $className;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,7 @@ class AclCheck implements Command
|
||||
}
|
||||
|
||||
if ($user->isPortal()) {
|
||||
/** @var string[] */
|
||||
$portalIdList = $user->getLinkMultipleIdList('portals');
|
||||
|
||||
foreach ($portalIdList as $portalId) {
|
||||
|
||||
Reference in New Issue
Block a user