Laravel Auth::user()

Please include the following information in your post:

  • Which SDK this is regarding: Laravel
  • SDK Version: auth0/login 7.1 / auth0/auth0-php 8.2.1
  • Platform Version: PHP 8.1, Laravel 9.25

I have an existing application that I built with standard built in authentication. As a result I reference auth()->user() all throughout my app and it returns a regular user model that’s looked up in my Users table.

I currently have auth0-php 7 implemented instead of the old Laravel package since the Auth0 Laravel package doesn’t return a User and instead returned an Auth0 class instead.

I’ve upgraded to Laravel 9 and at the same time I’m looking to bring my Auth0 package up to date. Auth0-PHP 8 requires some major updates anyways so I’m looking at implementing the Laravel package directly.

TLDR; Is there any way to configure the auth0-login laravel package so that auth()->user() returns an eloquent user instead of an instance of Auth0\Laravel\Model\Stateful\User?

Hi @stanley :wave: You could implement this sort of approach using custom user models and repositories. You can find an example of how to do this in the README.

1 Like