Passing the Auth Guard
Opened this issue ยท 7 comments
I want to use this on my authentication guard "member". Works great for my default auth guard, but Is there a way to pass the guard to get the user into this package?
I would imagine it could be done by adding a guard config option?
Yeah, we should probably improve things in this area.
Actually, this configuration doesn't help you?
/*
* Auth container binding
*/
'auth' => 'auth',
No, It generated a Class doesn't exist error.
So I did Downloaded the package, edited 2 files and placed in my project.
adding this to google2fa.php
'guard' => 'guard_name'
Setting the guard name or setting to null works
then in Support/Auth.php Line 35 of this package, placing:
return $this->getAuth()->guard($this->config('guard'))->user();
I second this. A guard configuration setting would really help. Currently I'm having to do the same.
For anyone struggling with this, I'm not sure if this is the correct solution but it is possible to use the auth container binding configuration. What I did, was creating an app binding for my auth guard in the AppServiceProvider, like below:
app()->bind('auth.guard', function () { return \Auth::guard('guard'); });
After that you can change the auth container config variable to the name of your binding like below and it should work!
/*
* Auth container binding
*/
'auth' => 'auth.guard',
This way you don't have to make any changes in the package itself and this seemed like the cleanest solution.
@erikstelt do you add it inside the boot method of the service provider or the register method?