Ensure tokens are found in the database using the expected logic
This commit is contained in:
parent
e9c633fd03
commit
f7fc67344e
5 changed files with 39 additions and 25 deletions
|
@ -195,9 +195,13 @@ class ApiKey extends Model
|
|||
public static function findToken($token)
|
||||
{
|
||||
$id = Str::substr($token, 0, self::IDENTIFIER_LENGTH);
|
||||
$token = Str::substr($token, strlen($id));
|
||||
|
||||
return static::where('identifier', $id)->where('token', encrypt($token))->first();
|
||||
$model = static::where('identifier', $id)->first();
|
||||
if (!is_null($model) && decrypt($model->token) === Str::substr($token, strlen($id))) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue