1111
1212namespace LucaDegasperi \OAuth2Server \Storage ;
1313
14+ use Illuminate \Contracts \Foundation \Application ;
1415use Illuminate \Support \ServiceProvider ;
1516use League \OAuth2 \Server \Storage \AccessTokenInterface ;
1617use League \OAuth2 \Server \Storage \AuthCodeInterface ;
@@ -43,49 +44,51 @@ public function boot()
4344 */
4445 public function register ()
4546 {
46- $ this ->registerStorageBindings ();
47- $ this ->registerInterfaceBindings ();
47+ $ this ->registerStorageBindings ($ this -> app );
48+ $ this ->registerInterfaceBindings ($ this -> app );
4849 }
4950
5051 /**
5152 * Bind the storage implementations to the IoC container.
5253 *
54+ * @param \Illuminate\Contracts\Foundation\Application $app
55+ *
5356 * @return void
5457 */
55- public function registerStorageBindings ()
58+ public function registerStorageBindings (Application $ app )
5659 {
5760 $ provider = $ this ;
5861
59- $ this -> app ->bindShared (FluentAccessToken::class, function () use ($ provider ) {
62+ $ app ->singleton (FluentAccessToken::class, function () use ($ provider ) {
6063 $ storage = new FluentAccessToken ($ provider ->app ['db ' ]);
6164 $ storage ->setConnectionName ($ provider ->getConnectionName ());
6265
6366 return $ storage ;
6467 });
6568
66- $ this -> app ->bindShared (FluentAuthCode::class, function () use ($ provider ) {
69+ $ app ->singleton (FluentAuthCode::class, function () use ($ provider ) {
6770 $ storage = new FluentAuthCode ($ provider ->app ['db ' ]);
6871 $ storage ->setConnectionName ($ provider ->getConnectionName ());
6972
7073 return $ storage ;
7174 });
7275
73- $ this -> app ->bindShared (FluentClient::class, function ($ app ) use ($ provider ) {
76+ $ app ->singleton (FluentClient::class, function ($ app ) use ($ provider ) {
7477 $ limitClientsToGrants = $ app ['config ' ]->get ('oauth2.limit_clients_to_grants ' );
7578 $ storage = new FluentClient ($ provider ->app ['db ' ], $ limitClientsToGrants );
7679 $ storage ->setConnectionName ($ provider ->getConnectionName ());
7780
7881 return $ storage ;
7982 });
8083
81- $ this -> app ->bindShared (FluentRefreshToken::class, function () use ($ provider ) {
84+ $ app ->singleton (FluentRefreshToken::class, function () use ($ provider ) {
8285 $ storage = new FluentRefreshToken ($ provider ->app ['db ' ]);
8386 $ storage ->setConnectionName ($ provider ->getConnectionName ());
8487
8588 return $ storage ;
8689 });
8790
88- $ this -> app ->bindShared (FluentScope::class, function ($ app ) use ($ provider ) {
91+ $ app ->singleton (FluentScope::class, function ($ app ) use ($ provider ) {
8992 $ limitClientsToScopes = $ app ['config ' ]->get ('oauth2.limit_clients_to_scopes ' );
9093 $ limitScopesToGrants = $ app ['config ' ]->get ('oauth2.limit_scopes_to_grants ' );
9194 $ storage = new FluentScope ($ provider ->app ['db ' ], $ limitClientsToScopes , $ limitScopesToGrants );
@@ -94,7 +97,7 @@ public function registerStorageBindings()
9497 return $ storage ;
9598 });
9699
97- $ this -> app ->bindShared (FluentSession::class, function () use ($ provider ) {
100+ $ app ->singleton (FluentSession::class, function () use ($ provider ) {
98101 $ storage = new FluentSession ($ provider ->app ['db ' ]);
99102 $ storage ->setConnectionName ($ provider ->getConnectionName ());
100103
@@ -105,16 +108,18 @@ public function registerStorageBindings()
105108 /**
106109 * Bind the interfaces to their implementations.
107110 *
111+ * @param \Illuminate\Contracts\Foundation\Application $app
112+ *
108113 * @return void
109114 */
110- public function registerInterfaceBindings ()
115+ public function registerInterfaceBindings (Application $ app )
111116 {
112- $ this -> app ->bind (ClientInterface::class, FluentClient::class);
113- $ this -> app ->bind (ScopeInterface::class, FluentScope::class);
114- $ this -> app ->bind (SessionInterface::class, FluentSession::class);
115- $ this -> app ->bind (AuthCodeInterface::class, FluentAuthCode::class);
116- $ this -> app ->bind (AccessTokenInterface::class, FluentAccessToken::class);
117- $ this -> app ->bind (RefreshTokenInterface::class, FluentRefreshToken::class);
117+ $ app ->bind (ClientInterface::class, FluentClient::class);
118+ $ app ->bind (ScopeInterface::class, FluentScope::class);
119+ $ app ->bind (SessionInterface::class, FluentSession::class);
120+ $ app ->bind (AuthCodeInterface::class, FluentAuthCode::class);
121+ $ app ->bind (AccessTokenInterface::class, FluentAccessToken::class);
122+ $ app ->bind (RefreshTokenInterface::class, FluentRefreshToken::class);
118123 }
119124
120125 /**
0 commit comments