Skip to content

Commit f834339

Browse files
authored
Merge pull request #66 from ResuBaka/master
Fixed problem that the oauth keys are loaded on boot
2 parents ac526cb + 04c4c9c commit f834339

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/Providers/LighthouseGraphQLPassportServiceProvider.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@ public function boot()
2626
if (config('lighthouse-graphql-passport.migrations')) {
2727
$this->loadMigrationsFrom(__DIR__.'/../../migrations');
2828
}
29-
app(AuthorizationServer::class)->enableGrantType($this->makeCustomRequestGrant(), Passport::tokensExpireIn());
30-
app(AuthorizationServer::class)->enableGrantType($this->makeLoggedInRequestGrant(), Passport::tokensExpireIn());
3129
}
3230

3331
public function register()
3432
{
33+
$this->extendAuthorizationServer();
3534
$this->registerConfig();
3635

3736
app('events')->listen(
@@ -102,4 +101,24 @@ protected function makeLoggedInRequestGrant()
102101

103102
return $grant;
104103
}
104+
105+
/**
106+
* Register the Grants.
107+
*
108+
* @return void
109+
*/
110+
protected function extendAuthorizationServer()
111+
{
112+
$this->app->extend(AuthorizationServer::class, function ($server) {
113+
return tap($server, function ($server) {
114+
$server->enableGrantType(
115+
$this->makeLoggedInRequestGrant(), Passport::tokensExpireIn()
116+
);
117+
118+
$server->enableGrantType(
119+
$this->makeCustomRequestGrant(), Passport::tokensExpireIn()
120+
);
121+
});
122+
});
123+
}
105124
}

0 commit comments

Comments
 (0)