Skip to content

Commit 2d4cf80

Browse files
Jordan Hoffmpociot
authored andcommitted
Adds authProvider and authGuard Options (mpociot#213)
* Adds authProvider Option * Add authGuard option too
1 parent cb009ca commit 2d4cf80

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Mpociot/ApiDoc/Commands/GenerateDocumentation.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@ class GenerateDocumentation extends Command
2020
*
2121
* @var string
2222
*/
23-
protected $signature = 'api:generate
23+
protected $signature = 'api:generate
2424
{--output=public/docs : The output path for the generated documentation}
2525
{--routePrefix= : The route prefix to use for generation}
2626
{--routes=* : The route names to use for generation}
2727
{--middleware= : The middleware to use for generation}
2828
{--noResponseCalls : Disable API response calls}
2929
{--noPostmanCollection : Disable Postman collection creation}
3030
{--useMiddlewares : Use all configured route middlewares}
31+
{--authProvider=users : The authentication provider to use for API response calls}
32+
{--authGuard=web : The authentication guard to use for API response calls}
3133
{--actAsUserId= : The user ID to use for API response calls}
3234
{--router=laravel : The router to be used (Laravel or Dingo)}
3335
{--force : Force rewriting of existing routes}
@@ -223,9 +225,10 @@ private function setUserToBeImpersonated($actAs)
223225
$user = $userModel::find((int) $actAs);
224226
$this->laravel['auth']->setUser($user);
225227
} else {
226-
$userModel = config('auth.providers.users.model');
228+
$provider = $this->option('authProvider');
229+
$userModel = config("auth.providers.$provider.model");
227230
$user = $userModel::find((int) $actAs);
228-
$this->laravel['auth']->guard()->setUser($user);
231+
$this->laravel['auth']->guard($this->option('authGuard'))->setUser($user);
229232
}
230233
}
231234
}

0 commit comments

Comments
 (0)