Skip to content

Commit 15851f1

Browse files
authored
Merge pull request #1 from Sysvale/feat/update-to-laravel-8-10
Feat/update to laravel 8 10
2 parents c897b65 + 85e75f5 commit 15851f1

File tree

3 files changed

+137
-10
lines changed

3 files changed

+137
-10
lines changed

composer.json

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "designmynight/laravel-mongodb-passport",
2+
"name": "sysvale/laravel-mongodb-passport",
33
"description": "A package to allow laravel/passport use with jenssegers/laravel-mongodb",
4-
"homepage": "https://github.com/designmynight/laravel-mongodb-passport",
4+
"homepage": "https://github.com/Sysvale/laravel-mongodb-passport",
55
"license": "MIT",
66
"keywords": [
77
"laravel",
@@ -10,30 +10,34 @@
1010
"laravel-passport",
1111
"mongodb",
1212
"passport",
13-
"designmynight"
13+
"sysvale"
1414
],
1515
"require": {
1616
"php": ">=7.1",
1717
"illuminate/support": "^5.5 || ^6.0",
18-
"jenssegers/mongodb": "3.3.* || 3.4.* || 3.5.* || 3.6.*",
19-
"laravel/passport": "6.0.* || 7.0.* || 7.4.* || 7.5.* || ^8.0 || ^9.0"
18+
"jenssegers/mongodb": "3.3.* || 3.4.* || 3.5.* || 3.6.* || 3.8.*",
19+
"laravel/passport": "6.0.* || 7.0.* || 7.4.* || 7.5.* || ^8.0 || ^9.0 || ^10"
2020
},
2121
"autoload": {
2222
"psr-4": {
23-
"DesignMyNight\\Mongodb\\": "src"
23+
"Sysvale\\Mongodb\\": "src"
2424
}
2525
},
2626
"authors": [
2727
{
2828
"name": "DesignMyNight",
2929
"email": "[email protected]",
3030
"role": "Support"
31+
},
32+
{
33+
"name": "Geidson",
34+
"email": "[email protected]"
3135
}
3236
],
3337
"extra": {
3438
"laravel": {
3539
"providers": [
36-
"DesignMyNight\\Mongodb\\MongodbPassportServiceProvider"
40+
"Sysvale\\Mongodb\\MongodbPassportServiceProvider"
3741
]
3842
}
3943
}

src/Console/ClientCommand.php

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?php
2+
3+
namespace DesignMyNight\Mongodb\Console;
4+
5+
use DesignMyNight\Mongodb\Passport\Client;
6+
use Laravel\Passport\ClientRepository;
7+
use Laravel\Passport\Console\ClientCommand as PassportClientCommand;
8+
9+
class ClientCommand extends PassportClientCommand
10+
{
11+
/**
12+
* Create a new personal access client.
13+
*
14+
* @param \Laravel\Passport\ClientRepository $clients
15+
* @return void
16+
*/
17+
protected function createPersonalClient(ClientRepository $clients)
18+
{
19+
$name = $this->option('name') ?: $this->ask(
20+
'What should we name the personal access client?',
21+
config('app.name').' Personal Access Client'
22+
);
23+
24+
$client = $clients->createPersonalAccessClient(
25+
null, $name, 'http://localhost'
26+
);
27+
28+
$this->info('Personal access client created successfully.');
29+
30+
$this->patchedOutputClientDetails($client);
31+
}
32+
33+
/**
34+
* Create a new password grant client.
35+
*
36+
* @param \Laravel\Passport\ClientRepository $clients
37+
* @return void
38+
*/
39+
protected function createPasswordClient(ClientRepository $clients)
40+
{
41+
$name = $this->option('name') ?: $this->ask(
42+
'What should we name the password grant client?',
43+
config('app.name').' Password Grant Client'
44+
);
45+
46+
$client = $clients->createPasswordGrantClient(
47+
null, $name, 'http://localhost'
48+
);
49+
50+
$this->info('Password grant client created successfully.');
51+
52+
$this->patchedOutputClientDetails($client);
53+
}
54+
55+
/**
56+
* Create a client credentials grant client.
57+
*
58+
* @param \Laravel\Passport\ClientRepository $clients
59+
* @return void
60+
*/
61+
protected function createClientCredentialsClient(ClientRepository $clients)
62+
{
63+
$name = $this->option('name') ?: $this->ask(
64+
'What should we name the client?',
65+
config('app.name').' ClientCredentials Grant Client'
66+
);
67+
68+
$client = $clients->create(
69+
null, $name, ''
70+
);
71+
72+
$this->info('New client created successfully.');
73+
74+
$this->patchedOutputClientDetails($client);
75+
}
76+
77+
/**
78+
* Create a authorization code client.
79+
*
80+
* @param \Laravel\Passport\ClientRepository $clients
81+
* @return void
82+
*/
83+
protected function createAuthCodeClient(ClientRepository $clients)
84+
{
85+
$userId = $this->option('user_id') ?: $this->ask(
86+
'Which user ID should the client be assigned to?'
87+
);
88+
89+
$name = $this->option('name') ?: $this->ask(
90+
'What should we name the client?'
91+
);
92+
93+
$redirect = $this->option('redirect_uri') ?: $this->ask(
94+
'Where should we redirect the request after authorization?',
95+
url('/auth/callback')
96+
);
97+
98+
$client = $clients->create(
99+
$userId, $name, $redirect, false, false, ! $this->option('public')
100+
);
101+
102+
$this->info('New client created successfully.');
103+
104+
$this->patchedOutputClientDetails($client);
105+
}
106+
107+
/**
108+
* Output the client's ID and secret key.
109+
*
110+
* @param \Laravel\Passport\Client $client
111+
* @return void
112+
*/
113+
protected function patchedOutputClientDetails(Client $client)
114+
{
115+
$this->line('<comment>Client ID:</comment> '.$client->id);
116+
$this->line('<comment>Client secret:</comment> '.$client->secret);
117+
}
118+
}

src/MongodbPassportServiceProvider.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@
44

55
use Illuminate\Support\ServiceProvider;
66
use DesignMyNight\Mongodb\Passport\AuthCode;
7+
use DesignMyNight\Mongodb\Console\ClientCommand;
78
use DesignMyNight\Mongodb\Passport\Bridge\RefreshTokenRepository;
89
use DesignMyNight\Mongodb\Passport\Client;
910
use DesignMyNight\Mongodb\Passport\PersonalAccessClient;
10-
use DesignMyNight\Mongodb\Passport\RefreshToken;
1111
use DesignMyNight\Mongodb\Passport\Token;
1212
use Laravel\Passport\Bridge\RefreshTokenRepository as PassportRefreshTokenRepository;
13+
use Laravel\Passport\Console\ClientCommand as PassportClientCommand;
1314
use Laravel\Passport\Passport;
1415

1516
class MongodbPassportServiceProvider extends ServiceProvider
1617
{
1718
/**
18-
* @return void
19-
*/
19+
* @return void
20+
*/
2021
public function register()
2122
{
2223
Passport::useAuthCodeModel(AuthCode::class);
@@ -27,5 +28,9 @@ public function register()
2728
$this->app->bind(PassportRefreshTokenRepository::class, function () {
2829
return $this->app->make(RefreshTokenRepository::class);
2930
});
31+
32+
$this->app->extend(PassportClientCommand::class, function () {
33+
return new ClientCommand();
34+
});
3035
}
3136
}

0 commit comments

Comments
 (0)