#1733 Patron yarısı - expense showing data (rapor gösterilmesi)

This commit is contained in:
Diatrex 2020-06-29 18:21:09 +03:00
parent d9c3d34118
commit dc124f7a00

View File

@ -4,28 +4,31 @@ use Anomaly\Streams\Platform\Addon\Extension\ExtensionCollection;
use Anomaly\UsersModule\User\Authenticator\Contract\AuthenticatorExtensionInterface; use Anomaly\UsersModule\User\Authenticator\Contract\AuthenticatorExtensionInterface;
use Anomaly\UsersModule\User\Contract\UserInterface; use Anomaly\UsersModule\User\Contract\UserInterface;
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface; use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Visiosoft\ProfileModule\Profile\Events\SendEmptyPassword; use Visiosoft\ProfileModule\Profile\Events\SendEmptyPassword;
use Visiosoft\ProfileModule\Profile\SignIn\SignInFormBuilder; use Visiosoft\ProfileModule\Profile\SignIn\SignInFormBuilder;
class ValidateCredentials class ValidateCredentials
{ {
private $extensions; private $extensions;
private $repository; private $repository;
private $dispatcher; private $dispatcher;
private $config;
public function __construct( public function __construct(
ExtensionCollection $extensions, ExtensionCollection $extensions,
UserRepositoryInterface $userRepository, UserRepositoryInterface $userRepository,
Dispatcher $dispatcher Dispatcher $dispatcher,
Repository $config
) )
{ {
$this->extensions = $extensions; $this->extensions = $extensions;
$this->repository = $userRepository; $this->repository = $userRepository;
$this->dispatcher = $dispatcher; $this->dispatcher = $dispatcher;
$this->config = $config;
} }
public function authenticate(array $credentials) public function authenticate(array $credentials)
@ -37,20 +40,22 @@ class ValidateCredentials
/* @var AuthenticatorExtensionInterface $authenticator */ /* @var AuthenticatorExtensionInterface $authenticator */
foreach ($authenticators as $authenticator) { foreach ($authenticators as $authenticator) {
if ($authenticator->slug == "default_authenticator") { if ($authenticator->slug == "default_authenticator") {
if (!isset($credentials['password']) && !isset($credentials['email'])) { $method = $this->config->get('anomaly.module.users::config.login');
if (!isset($credentials['password']) && !isset($credentials[$method])) {
$response = null; $response = null;
} }
//Is email or phone number //Is email/username or phone number
if (!filter_var($credentials['email'], FILTER_VALIDATE_EMAIL)) { if (!filter_var($credentials[$method], FILTER_VALIDATE_EMAIL)) {
$possiblePhone = $credentials['email']; $possiblePhone = $credentials[$method];
if (substr($credentials['email'], 0, 1) == 0) { if (substr($credentials[$method], 0, 1) == 0) {
$possiblePhone = substr($credentials['email'], 1); $possiblePhone = substr($credentials[$method], 1);
} }
if ($user = $this->repository if ($user = $this->repository
->newQuery() ->newQuery()
->where('gsm_phone', 'LIKE', "%$possiblePhone")->first()) { ->where('gsm_phone', 'LIKE', "%$possiblePhone")->first()) {
$credentials['email'] = $user->email; $credentials[$method] = $user->email;
} }
} }
$response = $this->repository->findByCredentials($credentials); $response = $this->repository->findByCredentials($credentials);