From within Tinker I am trying to:
>>> Auth::loginUsingId(12);
=> false
>>> Auth::user();
=> null
>>> Auth::attempt(['email' => '[email protected]']);
=> false
I am guessing that since Auth typically uses session data, and maybe sessions don't work with tinker.
Is it possible to authenticate within tinker?
It's possible to login in Tinker. For example:
auth()->loginUsingId(1)
auth()->id()
Normally, the output of the auth()->id()
will be 1
.
If it doesn't work for you, make sure the storage
directory is writable:
sudo chmod -R 755 storage
You're also doing it wrong when you're using the attempt()
method. The correct syntax is:
attempt(['email' => '[email protected]', 'password' => 'secret'])