Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend Illuminate\Foundation\Auth\User #104

Closed
dustinleblanc opened this issue Jun 5, 2018 · 13 comments
Closed

Extend Illuminate\Foundation\Auth\User #104

dustinleblanc opened this issue Jun 5, 2018 · 13 comments
Assignees

Comments

@dustinleblanc
Copy link

I've found that I am having to handle Auth0 user data and my database models separately which isn't very convenient. Using Eloquent's User::firstOrNew() isn't possible using Auth0User, but if decide to extend my user object from the default Eloquent object, I lose access to the added Auth0 data, I'd love to have peanut butter and chocolate 😄

@joshcanhelp
Copy link
Contributor

Thanks for the note here @dustinleblanc ... we have a section on our quickstart that addresses Auth0 login along with a database:

https://auth0.com/docs/quickstart/webapp/laravel#extra-custom-user-handling

Is that helpful or are you looking to do something else?

@dustinleblanc
Copy link
Author

dustinleblanc commented Jun 8, 2018

Hey @joshcanhelp ! That documentation was helpful during implementation, I've just run into a limitation running that setup. I can load my user from the database, and access all the data we define for the user in the database tables, or I can instead load the user using's Auth0's provided classes and get the Auth0 metadata for the user, but at the current time I can't really see how to load both sets of data on a single object. I'd like to have my user model extend the Auth0User class provided by the plugin, but if I do, I lose access to the Eloquent methods that let me load the user from the database (and I am sure some other things). It feels like this could work if the Auth0 user extended the eloquent user, or could be made to more easily. Thanks!

This isn't a deal breaker btw, more of an improvement. We currently have the app on Laravel 5.2 if that matters.

Thanks!

@joshcanhelp
Copy link
Contributor

What, exactly, are you trying to do that you're unable to? Would it be possible to extend the Eloquent model to extract that user data, using the Auth0 class as an example?

I'm definitely open to a different implementation here, as long as it doesn't mean we break everything!

@joshcanhelp
Copy link
Contributor

No activity, closing.

@joshcanhelp joshcanhelp added this to the 5.1.1 milestone Jun 27, 2019
@vomitHatSteve
Copy link

I don't know if this ticket should be re-opened but two use-cases include issue #114 and integrating with bouncer (https://github.com/JosephSilber/bouncer)

Apologies if necroing this thread is incorrect etiquette.

@joshcanhelp
Copy link
Contributor

@vomitHatSteve - "necroing" is my favorite word of the month now, thank you for that 😆

Happy to re-open this. We're working on a major in the 7.0.0 branch (not a lot there currently) and I'm guessing the changes required to get this working how it should will include some breakage.

I'm happy to take a first pass at this once we've got our SDK major released and working in the 7.0.0 branch here but open to PRs and suggestions in the meantime!

@joshcanhelp joshcanhelp reopened this Dec 6, 2019
@joshcanhelp joshcanhelp removed this from the 5.2.0 milestone Dec 6, 2019
@saltukalakus
Copy link

Hi @joshcanhelp , @lbalmaceda just wanted to put a brief note here as well for the internal eng. issue. I was able to reproduce the issue using this repository. Let me know if I can with anything else.

@joshcanhelp joshcanhelp self-assigned this Dec 29, 2019
@joshcanhelp joshcanhelp added this to the 7.0.0 milestone Dec 30, 2019
@joshcanhelp
Copy link
Contributor

@vomitHatSteve @saltukalakus - Would you be able to give the change-user-model branch a try and see if it works for you?

https://github.com/auth0/laravel-auth0/tree/change-user-model

@vomitHatSteve
Copy link

This branch doesn't appear to introduce new issues for me, but I'm still stymied by #158 unfortunately.

@rlewkowicz
Copy link

I'm running into issues as well and I'm not skilled enough yet to fully understand it. I believe its that the user provider is not extending the native model? So I can't do something like:

Auth::guard(app('VoyagerGuard'))->getProvider()->getModel();

Its making it difficult to use some of these open source packages

@joshcanhelp
Copy link
Contributor

@rlewkowicz - Does this branch solve your issue?

https://github.com/auth0/laravel-auth0/tree/change-user-model

Requires PHP 7.1, FYI.

@joshcanhelp joshcanhelp removed this from the 6.0.0 milestone Apr 9, 2020
@joshcanhelp
Copy link
Contributor

We took a different approach here based on feedback. Please see the draft PR below to see what we're proposing:

#165

That new trait can be added to the Eloquent User model which can be returned from a custom User repository. If anyone has feedback on this, we'd appreciate it!

@evansims
Copy link
Member

Closing this ticket as it's quite stale at this point, but the next major of this Laravel plugin will include a refactored user model that will address this, based on the work in the PR Josh linked above

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants