Files
UNIT3D-Community-Edition/app/Providers/CacheUserProvider.php
HDVinnie 3650900c97 update: lint
- not_operator_with_space to false
2023-02-03 16:01:29 -05:00

46 lines
1.2 KiB
PHP

<?php
/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author HDVinnie <hdinnovations@protonmail.com>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/
namespace App\Providers;
use App\Helpers\CacheUser;
use App\Models\User;
use Illuminate\Auth\EloquentUserProvider;
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
class CacheUserProvider extends EloquentUserProvider
{
public function __construct(HasherContract $hasher)
{
parent::__construct($hasher, User::class);
}
public function retrieveById($identifier)
{
return CacheUser::user($identifier);
}
public function retrieveByToken($identifier, $token)
{
$model = CacheUser::user($identifier);
if (! $model) {
return;
}
$rememberToken = $model->getRememberToken();
return $rememberToken && hash_equals($rememberToken, $token) ? $model : null;
}
}