Skip to content

Conversation

inmanturbo
Copy link

@inmanturbo inmanturbo commented Feb 27, 2025

#2
#1

Workos supports a wide range of clients and protocols. This PR Uses the service container for the workos services, so that they can be decorated or extended on a per case, per needs basis by the developer, rather than attempt to support the delta of every possible use case here manually.

Edit: Also adds a makeUsing callback to the AuthKitAuthenticationRequest

Example Usage:

// routes/auth.php

use Illuminate\Support\Facades\Route;
use Laravel\WorkOS\Http\Requests\AuthKitAuthenticationRequest;
use Laravel\WorkOS\User;
use WorkOS\Resource\AuthenticationResponse;

Route::get('authenticate', function (AuthKitAuthenticationRequest $request) {
    return tap(to_route('dashboard'), fn () => $request->authenticate(makeUsing: function (AuthenticationResponse $response) {
        $user = $response->user;

        return new class($user->id, $user->firstName, $user->lastName, $user->email, $user->profilePictureUrl, $response->organizationId) extends User
        {
            public function __construct(
                public string $id,
                public ?string $firstName,
                public ?string $lastName,
                public string $email,
                public ?string $avatar,
                public ?string $organizationId,
            ) {}
        };
    }));
})->middleware(['guest']);

Copy link

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@inmanturbo inmanturbo marked this pull request as ready for review February 27, 2025 16:11
@inmanturbo inmanturbo marked this pull request as draft February 27, 2025 16:59
@inmanturbo inmanturbo marked this pull request as ready for review February 27, 2025 17:53
@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions!

@inmanturbo
Copy link
Author

>>>notes<<<

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/inmanturbo/workos.git"
        }
    ]
}
{
    "require": {
        "laravel/workos": "dev-service-container",
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants