1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 07:02:34 +01:00
invoiceninja/app/Utils/Traits/User/LoginCache.php

33 lines
764 B
PHP
Raw Normal View History

2021-05-23 10:43:50 +02:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2022-04-27 05:20:41 +02:00
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
2021-05-23 10:43:50 +02:00
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
2021-05-23 10:43:50 +02:00
*/
namespace App\Utils\Traits\User;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
trait LoginCache
{
public function setLoginCache($user)
{
$timeout = $user->company()->default_password_timeout;
if ($timeout == 0) {
$timeout = 30 * 60 * 1000 * 1000;
} else {
$timeout = $timeout / 1000;
}
2021-05-23 10:43:50 +02:00
Cache::put($user->hashed_id.'_'.$user->account_id.'_logged_in', Str::random(64), $timeout);
}
}