Aragorn52 / Payload by Aragorn52

this library for payload from access token in lumen passport
50
0
1
Package Data
Maintainer Username: Aragorn52
Maintainer Contact: pobeda.deda1945@gmail.com (Aragorn52)
Package Create Date: 2022-09-16
Package Last Update: 2022-09-20
Language: PHP
License: proprietary
Last Refreshed: 2024-05-04 15:15:32
Package Statistics
Total Downloads: 50
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

Payload-token

Library to add payload to Access token for lumen passport

Dependencies

  • PHP >= 8.1
  • Lumen >= 9.0
  • Lumen-passport: >= 0.1.1

Installation via Composer

$ composer require payloadtoken/aragorn52

Or if you prefer, edit composer.json manually:

{
    "require": {
        "payloadtoken/aragorn52": "^1.0"
    }
}

Modify the bootstrap flow (bootstrap/app.php file)

$app->register(\Payload\Providers\PassportServiceProvider::class);

Create YourCustomClaimService. Extends \Payload\Services\AbstractClaimService

in method addCustomClaim add for claimCollection your claims

id user can be obtained by accessing the $this->id property YourCustomClaimService

class YourCustomClaimService extends \Payload\Services\AbstractClaimService
{
    public function addCustomClaims(): void
    {
        $this->claimCollection->add('test', 'testClaim');
        $this->claimCollection->add('test2', 'testClaim2');
    }
}

Modify the AppServiceProvider flow (app/Providers/PassportServiceProvider) add this code in method boot()

    public function boot()
    {
        $this->app->bind(\Payload\Services\AbstractClaimService::class, fn () => new YourCustomClaimService());
    }