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

Possible to use User object functions? #114

Closed
glaesser opened this issue Jan 10, 2019 · 7 comments
Closed

Possible to use User object functions? #114

glaesser opened this issue Jan 10, 2019 · 7 comments
Milestone

Comments

@glaesser
Copy link

Before integrating Auth0 into my app, I was able to call

Auth::user()->someFunction();

someFunction() was defined as a public function in my App\User.php. After integrating Auth0, I am no longer able to call these functions:

Call to undefined method Auth0\Login\Auth0User::someFunction()

My question is, what is the best way to still utilize these user model functions? I am using customUserRepository.php as outlined in the laravel quickstart guide.

@glaesser
Copy link
Author

Perhaps a better way to phrase my question is, how can I continue to use the eloquent user driver (providing access to various App\User.php functionality) while still performing login/logout using Auth0? I don't see anything related to this in the quickstart docs.

@joshcanhelp
Copy link
Contributor

@glaesser - Thanks for the report here! I'll take a look at this as soon as I can next week.

@glaesser
Copy link
Author

Just an update here that I've essentially solved this drawback by replacing all my app calls of Auth::user() with a custom function User::current() whenever I want to interact with the currently logged in user eloquent object:

...in App\User.php:

//return the currently logged-in user
public static function current() {
        if(Auth::check()) {
            return User::find(Auth::user()->id);
        } else {
            return null;
        }
    })

There are a few very minor drawbacks as inside blade templates you now have to reference App\User::current() instead of just Auth::user(), but for the most part it's completely solved the issue. Feel free to close this.

@joshcanhelp
Copy link
Contributor

Thanks for the update here, @glaesser. I'll make a note to see how this works now and if we can improve what we're doing here. We definitely don't want to clobber any existing functionality.

@betysam55
Copy link

is there any way to use user role and permission on auth0 like Auth::user() @can

@handhikadj
Copy link

I'm having this issue.
I have isAdmin method in User.php and now my Laravel app is squawking "Call to undefined method Auth0\Login\Auth0User::isAdmin()"

This is serious issue tho for me

@ionut-tanasa
Copy link

+1 issue still there

@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

No branches or pull requests

5 participants