@@ -33,6 +33,7 @@ class Auth
3333 */
3434 public const SHIELD_VERSION = '1.0.0-beta.7 ' ;
3535
36+ protected AuthConfig $ config ;
3637 protected ?Authentication $ authenticate = null ;
3738
3839 /**
@@ -42,16 +43,18 @@ class Auth
4243
4344 protected ?UserModel $ userProvider = null ;
4445
46+ public function __construct (AuthConfig $ config )
47+ {
48+ $ this ->config = $ config ;
49+ }
50+
4551 protected function ensureAuthentication (): void
4652 {
4753 if ($ this ->authenticate !== null ) {
4854 return ;
4955 }
5056
51- /** @var AuthConfig $config */
52- $ config = config ('Auth ' );
53-
54- $ authenticate = new Authentication ($ config );
57+ $ authenticate = new Authentication ($ this ->config );
5558 $ authenticate ->setProvider ($ this ->getProvider ());
5659
5760 $ this ->authenticate = $ authenticate ;
@@ -150,14 +153,11 @@ public function getProvider(): UserModel
150153 return $ this ->userProvider ;
151154 }
152155
153- /** @var \CodeIgniter\Shield\Config\Auth $config */
154- $ config = config ('Auth ' );
155-
156- if (! property_exists ($ config , 'userProvider ' )) {
156+ if (! property_exists ($ this ->config , 'userProvider ' )) {
157157 throw AuthenticationException::forUnknownUserProvider ();
158158 }
159159
160- $ className = $ config ->userProvider ;
160+ $ className = $ this -> config ->userProvider ;
161161 $ this ->userProvider = new $ className ();
162162
163163 return $ this ->userProvider ;
0 commit comments