Add pool interfaces, refactor imports in the bootstrap, re-organize some of the APIs
This commit is contained in:
parent
7f05554f4e
commit
e58c442ccf
@ -2,41 +2,33 @@
|
|||||||
|
|
||||||
namespace Slovocast;
|
namespace Slovocast;
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
|
||||||
use Slim\App;
|
|
||||||
use Slim\Factory\AppFactory;
|
|
||||||
|
|
||||||
use League\Config\Configuration;
|
|
||||||
|
|
||||||
use Psr\Container\ContainerInterface;
|
|
||||||
use Psr\Http\Message\ResponseFactoryInterface;
|
|
||||||
use DI\Container;
|
use DI\Container;
|
||||||
use DI\ContainerBuilder;
|
use DI\ContainerBuilder;
|
||||||
|
use Exception;
|
||||||
use Slim\Psr7\Factory\ResponseFactory;
|
use League\Config\Configuration;
|
||||||
|
|
||||||
use Slovocast\Configuration\SiteInformationSchema;
|
|
||||||
use Slovocast\Configuration\DatabaseConnectionSchema;
|
|
||||||
use Slovocast\Configuration\SessionSchema;
|
|
||||||
|
|
||||||
use Twig\Error\LoaderError;
|
|
||||||
use Slovocast\Domain\Repository\User\UserRepositoryInterface;
|
|
||||||
use Slovocast\Domain\Repository\User\UserRepository;
|
|
||||||
|
|
||||||
use Slovocast\Infrastructure\User\UserAuthorizationInterface;
|
|
||||||
use Slovocast\Infrastructure\User\BasicUserAuthorization;
|
|
||||||
|
|
||||||
use React\Mysql\MysqlClient;
|
|
||||||
|
|
||||||
use Psr\Log\LoggerInterface;
|
|
||||||
use Monolog\Logger;
|
|
||||||
use Monolog\Handler\StreamHandler;
|
use Monolog\Handler\StreamHandler;
|
||||||
use Monolog\Level;
|
use Monolog\Level;
|
||||||
|
use Monolog\Logger;
|
||||||
use Odan\Session\PhpSession;
|
use Odan\Session\PhpSession;
|
||||||
use Odan\Session\SessionInterface;
|
use Odan\Session\SessionInterface;
|
||||||
use Odan\Session\SessionManagerInterface;
|
use Odan\Session\SessionManagerInterface;
|
||||||
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
|
use Psr\Container\ContainerInterface;
|
||||||
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
|
use Psr\Http\Message\ResponseFactoryInterface;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use React\Mysql\MysqlClient;
|
||||||
|
use Slim\App;
|
||||||
|
use Slim\Factory\AppFactory;
|
||||||
|
use Slim\Psr7\Factory\ResponseFactory;
|
||||||
|
use Slovocast\Configuration\DatabaseConnectionSchema;
|
||||||
|
use Slovocast\Configuration\SessionSchema;
|
||||||
|
use Slovocast\Configuration\SiteInformationSchema;
|
||||||
|
use Slovocast\Domain\Repository\User\UserRepository;
|
||||||
|
use Slovocast\Domain\Repository\User\UserRepositoryInterface;
|
||||||
|
use Slovocast\Infrastructure\Api\User\UserAuthorizationInterface;
|
||||||
|
use Slovocast\Infrastructure\User\BasicUserAuthorization;
|
||||||
|
use Twig\Error\LoaderError;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines here are used globally
|
* Defines here are used globally
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace Slovocast\Controller\User;
|
namespace Slovocast\Controller\User;
|
||||||
|
|
||||||
|
use Odan\Session\SessionInterface;
|
||||||
|
use Psr\Http\Message\ResponseInterface as Response;
|
||||||
use Slovocast\Controller\Controller;
|
use Slovocast\Controller\Controller;
|
||||||
use Slovocast\Domain\Repository\User\UserRepositoryInterface;
|
use Slovocast\Domain\Repository\User\UserRepositoryInterface;
|
||||||
use Slovocast\Infrastructure\User\UserAuthorizationInterface;
|
|
||||||
use Slovocast\Exception\EntityNotFoundException;
|
use Slovocast\Exception\EntityNotFoundException;
|
||||||
use Psr\Http\Message\ResponseInterface as Response;
|
use Slovocast\Infrastructure\Api\User\UserAuthorizationInterface;
|
||||||
use Odan\Session\SessionInterface;
|
|
||||||
|
|
||||||
class LoginUserAction extends Controller
|
class LoginUserAction extends Controller
|
||||||
{
|
{
|
||||||
@ -34,7 +34,7 @@ class LoginUserAction extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// start the session
|
// start the session
|
||||||
$this->session->set('user', [
|
$this->session->set('user', [
|
||||||
'id' => $user->getId(),
|
'id' => $user->getId(),
|
||||||
'authenticated' => true
|
'authenticated' => true
|
||||||
]);
|
]);
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
namespace Slovocast\Domain\Repository\User;
|
namespace Slovocast\Domain\Repository\User;
|
||||||
|
|
||||||
use function React\Async\await;
|
|
||||||
use React\Mysql\MysqlClient;
|
use React\Mysql\MysqlClient;
|
||||||
use Slovocast\Infrastructure\User\UserAuthorizationInterface;
|
|
||||||
use Slovocast\Exception\EntityNotFoundException;
|
|
||||||
use Slovocast\Domain\Entity\User;
|
use Slovocast\Domain\Entity\User;
|
||||||
|
use Slovocast\Exception\EntityNotFoundException;
|
||||||
|
use Slovocast\Infrastructure\Api\User\UserAuthorizationInterface;
|
||||||
|
use function React\Async\await;
|
||||||
|
|
||||||
class UserRepository implements UserRepositoryInterface
|
class UserRepository implements UserRepositoryInterface
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Slovocast\Infrastructure\Api\Database;
|
namespace Slovocast\Infrastructure\Api\Database;
|
||||||
|
|
||||||
interface ConnectionInterface
|
interface PooledConnectionInterface
|
||||||
{
|
{
|
||||||
public function release(): void;
|
public function release(): void;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,8 @@ namespace Slovocast\Infrastructure\Api\Database;
|
|||||||
|
|
||||||
interface ConnectionPoolInterface
|
interface ConnectionPoolInterface
|
||||||
{
|
{
|
||||||
public function getTotalConnectionCount(): int;
|
public function getFreeConnectionsCount(): int;
|
||||||
|
public function getActiveConnectionsCount(): int;
|
||||||
public function hasFreeConnection(): bool;
|
public function hasFreeConnection(): bool;
|
||||||
public function getConnection(): ConnectionInterface;
|
public function getConnection(): ConnectionInterface;
|
||||||
public function releaseConnection(ConnectionInterface $connection): void;
|
public function releaseConnection(ConnectionInterface $connection): void;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Slovocast\Infrastructure\User;
|
namespace Slovocast\Infrastructure\Api\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple interface for securing and checking secured passwords for a user
|
* A simple interface for securing and checking secured passwords for a user
|
||||||
*/
|
*/
|
||||||
interface UserAuthorizationInterface
|
interface UserAuthorizationInterface
|
||||||
{
|
{
|
||||||
public function hash(string $password): string;
|
public function hash(string $password): string;
|
||||||
public function verify(string $password, string $hash): bool;
|
public function verify(string $password, string $hash): bool;
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Slovocast\Infrastructure\User;
|
namespace Slovocast\Infrastructure\User;
|
||||||
|
|
||||||
use Slovocast\Infrastructure\User\UserAuthorizationInterface;
|
use Slovocast\Infrastructure\Api\User\UserAuthorizationInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This empty class will essentially just check hashed passwords passed into it
|
* This empty class will essentially just check hashed passwords passed into it
|
||||||
@ -15,7 +15,7 @@ class BasicUserAuthorization implements UserAuthorizationInterface
|
|||||||
return password_hash($password, PASSWORD_BCRYPT);
|
return password_hash($password, PASSWORD_BCRYPT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function verify(string $password, string $hash): bool
|
public function verify(string $password, string $hash): bool
|
||||||
{
|
{
|
||||||
return password_verify($password, $hash);
|
return password_verify($password, $hash);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user