Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
hafezdivandari committed Sep 30, 2024
1 parent 7458bfd commit c4368a3
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 23 deletions.
1 change: 1 addition & 0 deletions database/factories/ClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public function asDeviceCodeClient(): static
{
return $this->state([
'grant_types' => ['urn:ietf:params:oauth:grant-type:device_code', 'refresh_token'],
'redirect_uris' => [],
]);
}
}
8 changes: 5 additions & 3 deletions src/DeviceCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ class DeviceCode extends Model
/**
* The guarded attributes on the model.
*
* @var array
* @var array<string>|bool
*/
protected $guarded = [];
protected $guarded = false;

/**
* The attributes that should be cast to native types.
*
* @var array
* @var array<string, \Illuminate\Contracts\Database\Eloquent\Castable|string>
*/
protected $casts = [
'scopes' => 'array',
Expand All @@ -57,6 +57,8 @@ class DeviceCode extends Model

/**
* Get the client that owns the authentication code.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Laravel\Passport\Client, $this>
*/
public function client(): BelongsTo
{
Expand Down
7 changes: 4 additions & 3 deletions src/Http/Controllers/ApproveDeviceAuthorizationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ class ApproveDeviceAuthorizationController
/**
* Create a new controller instance.
*/
public function __construct(protected AuthorizationServer $server,
protected ApprovedDeviceAuthorizationResponse $response)
{
public function __construct(
protected AuthorizationServer $server,
protected ApprovedDeviceAuthorizationResponse $response
) {
}

/**
Expand Down
7 changes: 4 additions & 3 deletions src/Http/Controllers/DenyDeviceAuthorizationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ class DenyDeviceAuthorizationController
/**
* Create a new controller instance.
*/
public function __construct(protected AuthorizationServer $server,
protected DeniedDeviceAuthorizationResponse $response)
{
public function __construct(
protected AuthorizationServer $server,
protected DeniedDeviceAuthorizationResponse $response
) {
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/Http/Controllers/DeviceAuthorizationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ class DeviceAuthorizationController
/**
* Create a new controller instance.
*/
public function __construct(protected DeviceAuthorizationViewResponse $viewResponse)
{
public function __construct(
protected DeviceAuthorizationViewResponse $viewResponse
) {
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/Http/Controllers/DeviceCodeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ class DeviceCodeController
/**
* Create a new controller instance.
*/
public function __construct(protected AuthorizationServer $server)
{
public function __construct(
protected AuthorizationServer $server
) {
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/Http/Controllers/DeviceUserCodeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ class DeviceUserCodeController
/**
* Create a new controller instance.
*/
public function __construct(protected DeviceUserCodeViewResponse $viewResponse)
{
public function __construct(
protected DeviceUserCodeViewResponse $viewResponse
) {
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/Passport.php
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,8 @@ public static function authorizationView(Closure|string $view): void

/**
* Specify which view should be used as the device authorization view.
*
* @param (\Closure(array<string, mixed>): (\Symfony\Component\HttpFoundation\Response))|string $view
*/
public static function deviceAuthorizationView(Closure|string $view): void
{
Expand All @@ -606,6 +608,8 @@ public static function deviceAuthorizationView(Closure|string $view): void

/**
* Specify which view should be used as the device user code view.
*
* @param (\Closure(array<string, mixed>): (\Symfony\Component\HttpFoundation\Response))|string $view
*/
public static function deviceUserCodeView(Closure|string $view): void
{
Expand Down
14 changes: 6 additions & 8 deletions src/PassportServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,17 @@ protected function makeImplicitGrant(): ImplicitGrant
*/
protected function makeDeviceCodeGrant(): DeviceCodeGrant
{
$grant = new DeviceCodeGrant(
return tap(new DeviceCodeGrant(
$this->app->make(DeviceCodeRepository::class),
$this->app->make(RefreshTokenRepository::class),
new DateInterval('PT10M'),
route('passport.device'),
5
);

$grant->setRefreshTokenTTL(Passport::refreshTokensExpireIn());
$grant->setIncludeVerificationUriComplete(true);
$grant->setIntervalVisibility(true);

return $grant;
), function (DeviceCodeGrant $grant) {
$grant->setRefreshTokenTTL(Passport::refreshTokensExpireIn());
$grant->setIncludeVerificationUriComplete(true);
$grant->setIntervalVisibility(true);
});
}

/**
Expand Down

0 comments on commit c4368a3

Please sign in to comment.