Skip to content

Commit 7b3ffe5

Browse files
authored
Ajusta classe Client adicionado função hasGrantType (#9)
* Ajusta classe Client adicionado função hasGrantType * Altera versão do compose.json
1 parent ac5338a commit 7b3ffe5

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sysvale/laravel-mongodb-passport",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"description": "A package to allow laravel/passport use with mongodb/laravel-mongodb",
55
"homepage": "https://github.com/Sysvale/laravel-mongodb-passport",
66
"license": "MIT",

src/Passport/Client.php

+22-7
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static function boot()
6666
parent::boot();
6767

6868
static::creating(function ($model) {
69-
if (config('passport.client_uuids')) {
69+
if (Passport::clientUuids()) {
7070
$model->{$model->getKeyName()} = $model->{$model->getKeyName()} ?: (string) Str::orderedUuid();
7171
}
7272
});
@@ -80,6 +80,7 @@ public static function boot()
8080
public function user()
8181
{
8282
$provider = $this->provider ?: config('auth.guards.api.provider');
83+
8384
return $this->belongsTo(
8485
config("auth.providers.{$provider}.model")
8586
);
@@ -158,6 +159,21 @@ public function skipsAuthorization()
158159
return false;
159160
}
160161

162+
/**
163+
* Determine if the client has the given grant type.
164+
*
165+
* @param string $grantType
166+
* @return bool
167+
*/
168+
public function hasGrantType($grantType)
169+
{
170+
if (! isset($this->attributes['grant_types']) || ! is_array($this->grant_types)) {
171+
return true;
172+
}
173+
174+
return in_array($grantType, $this->grant_types);
175+
}
176+
161177
/**
162178
* Determine whether the client has the given scope.
163179
*
@@ -166,7 +182,7 @@ public function skipsAuthorization()
166182
*/
167183
public function hasScope($scope)
168184
{
169-
if (!is_array($this->scopes)) {
185+
if (! isset($this->attributes['scopes']) || ! is_array($this->scopes)) {
170186
return true;
171187
}
172188

@@ -218,9 +234,8 @@ public function getIncrementing()
218234
*
219235
* @return \Illuminate\Database\Eloquent\Factories\Factory
220236
*/
221-
public static function newFactory()
222-
{
223-
return ClientFactory::new();
224-
}
225-
237+
// public static function newFactory()
238+
// {
239+
// return ClientFactory::new();
240+
// }
226241
}

0 commit comments

Comments
 (0)