laravel-auth0: Error on custom repository and model

Laravel Version

Laravel 10.x

SDK Version

SDK 7.7

PHP Version

PHP 8.3

What happened?

Hello,

I’m attempting to implement a custom repository that utilizes Eloquent ORM (from this link - https://github.com/auth0/laravel-auth0/blob/main/docs/User Models and Repositories.md), but I’ve encountered an error: Call to undefined method App\Models\User::where(). I believe the issue stems from the fact that the Auth0\Laravel\Model\User class does not extend the Laravel model, resulting in the absence of a ::where() method.

Could you please tell me what went wrong with the integration process based on the above documentation?

Thank you.

How can we reproduce this issue?

na

Additional context

na

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 2
  • Comments: 17 (9 by maintainers)

Most upvoted comments

Curious if there’s any movement on this? Or a short term workaround? I’m having the same issue.

I share your frustration with recent regressions and incompatibilities @squpshift.

I’m working on a Laravel 10 upgrade which will take my auth0/login from 7.4 up to at least 7.5. I’d have loved to try the 7.8 series but its clearly not feasible right now in its current state.

My suggestion (and what I’ll be doing in the next few days) is pinning my dependency to either 7.5.* or 7.6.* in an effort to avoid the 7.8 mess. Sadly there’s not as clear documentation for those versions but the interfaces & abstractions are at least relatively clear once you dive into the code. Happy to share back if I find a happy path in doing so.

We have an application that is ready to launch except it seems to be impossible to integrate auth0 with a Laravel eloquent user model at the moment.

I’m really struggling to understand why the current implementation of this library requires a \App\Models\User that does not extend \Illuminate\Database\Eloquent\Model

I’ve been battling with this for so many hours trying to make it work.

Does anyone have a workaround they could suggest or are we stuck waiting for auth0 team to fix this?

I’ve found that implementing UserContract is not actually required, as the SDK typehints against Laravel’s Authenticable contract. The former interface appears to be redundant. I suggest removing it to reduce the complexity.

One thing that really bothers me with the current implementation is that during the code exchange UserRepository::fromSession() receives the decoded JWT, while on subsequent calls (when authenticated) it receives a serialized version of the model that was returned from fromSession(). I’m doing a hacky isset($user[...]) workaround to determine which type it is. Ideally the SDK just stores the user identifier (Authenticatable::getAuthIdentifier()) in the session, similar to Laravel’s SessionGuard.

By the way, the AuthenticationGuard doesn’t implement Laravel’s Illuminate\Contracts\Auth\Guard interface. So this potentially breaks code that depends on a Guard implementation when interacting with other parts of the framework.