Open ivansammartino opened 6 years ago
Hi there,
I'm sorry for my late response here, looks like I didn't receive a notification for this.
The main reason I wrote this was to be able to use the actingAs()
method when writing tests. Therefore I did not include the authorization part of it.
When you use Auth::user()
to retrieve the authenticated user it will return an instance of Rojtjo\SentinelGuard\User
which extends the default Cartalyst\Sentinel\Users\EloquentUser
.
Neither of these classes use Illuminate\Foundation\Auth\Access\Authorizable
which provided the can()
method. You should however be able to extend the Rojtjo\SentinelGuard\User
class and then use the Illuminate\Foundation\Auth\Access\Authorizable
trait on it.
Detailed description
Hello, I'm a Laravel novice. I'm not sure if I'm misunderstanding the use of sentinel-guard, but I am encountering a couple of issues, hope you can help...
I setup simple routes like this, just to test (the first route authenticates through Sentinel, the second retrieves user via Auth):
So far so good! I can authenticate with powerful Sentinel and then "switch" to use native Laravel Auth's method (is this the intended purpose of the class, right?)
But when I try to retrieve the user ID with
$user = Auth::id();
I get an errorCall to undefined method Illuminate\Database\Query\Builder::getAuthIdentifier()
Also when I try to see if user can do some task with:
I get this error:
Call to undefined method Illuminate\Database\Query\Builder::can()
Did I understand the purpose of the class? Or am I totally wrong?
My environment: Windows 10 (Laragon), Laravel, 5.5.*, PHP 7.1.2