2021-08-23 13:05:16 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Modules\Auth\Config;
|
|
|
|
|
2022-10-15 13:22:08 +02:00
|
|
|
use CodeIgniter\Shield\Authentication\Authentication;
|
|
|
|
use Config\Services as BaseService;
|
|
|
|
use Modules\Auth\Auth;
|
2023-08-27 15:26:06 +02:00
|
|
|
use Modules\Auth\Config\Auth as AuthConfig;
|
2021-08-23 13:05:16 +02:00
|
|
|
|
|
|
|
class Services extends BaseService
|
|
|
|
{
|
|
|
|
/**
|
2022-10-15 13:22:08 +02:00
|
|
|
* The base auth class
|
2021-08-23 13:05:16 +02:00
|
|
|
*/
|
2022-10-15 13:22:08 +02:00
|
|
|
public static function auth(bool $getShared = true): Auth
|
|
|
|
{
|
2021-08-23 13:05:16 +02:00
|
|
|
if ($getShared) {
|
2023-08-27 15:26:06 +02:00
|
|
|
/** @var Auth */
|
2022-10-15 13:22:08 +02:00
|
|
|
return self::getSharedInstance('auth');
|
2021-08-23 13:05:16 +02:00
|
|
|
}
|
|
|
|
|
2023-08-27 15:26:06 +02:00
|
|
|
$config = config(AuthConfig::class);
|
2021-08-23 13:05:16 +02:00
|
|
|
|
2022-10-15 13:22:08 +02:00
|
|
|
return new Auth(new Authentication($config));
|
2021-08-23 13:05:16 +02:00
|
|
|
}
|
|
|
|
}
|