Dies sollte nicht der Fall sein. Laravel versucht, resolve the token in several ways first
* Get the token for the current request.
*
* @return string
*/
public function getTokenForRequest()
{
$token = $this->request->query($this->inputKey);
if (empty($token)) {
$token = $this->request->input($this->inputKey);
}
if (empty($token)) {
$token = $this->request->bearerToken();
}
if (empty($token)) {
$token = $this->request->getPassword();
}
return $token;
}
Wo diese Methode aufgerufen wird, wenn attempting to resolve an instance of the user:
/**
* Get the currently authenticated user.
*
* @return \Illuminate\Contracts\Auth\Authenticatable|null
*/
public function user()
{
// If we've already retrieved the user for the current request we can just
// return it back immediately. We do not want to fetch the user data on
// every call to this method because that would be tremendously slow.
if (! is_null($this->user)) {
return $this->user;
}
$user = null;
$token = $this->getTokenForRequest();
if (! empty($token)) {
$user = $this->provider->retrieveByCredentials(
[$this->storageKey => $token]
);
}
return $this->user = $user;
}
Und die provider
in diesem Fall ist die DatabaseUserProvider
, die das Verfahren retrieveByCredentials
performs a strict case-sensitive check die Datenbank Fabriken ->where()
Methode, kein wie wird verwendet, können Sie das hier sehen:
public function retrieveByCredentials(array $credentials)
{
// First we will add each credential element to the query as a where clause.
// Then we can execute the query and, if we found a user, return it in a
// generic "user" object that will be utilized by the Guard instances.
$query = $this->conn->table($this->table);
foreach ($credentials as $key => $value) {
if (! Str::contains($key, 'password')) {
$query->where($key, $value);
}
}
// Now we are ready to execute the query to see if we have an user matching
// the given credentials. If not, we will just return nulls and indicate
// that there are no matching users for these given credential arrays.
$user = $query->first();
return $this->getGenericUser($user);
}
Also nein, dein Fall ist nicht typisch, und wahrscheinlich gibt es hier andere Komponenten, die wir nicht kennen.
Ok, ich werde einen tieferen Blick haben. Aber wie ich sagte, ich entwickle mich auf einer neuen Laravel-Installation. Nichts besonderes, außer dass es mein Dev-Mac ist. Ich überprüfe mein Skript auf einer Vagrant-Installation, um zu überprüfen, ob mein Mac das zugrundeliegende Problem ist. Vielen Dank für Ihre Antwort! –