3 * @copyright Copyright (C) 2010-2022, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Security\TwoFactor\Model;
24 use Friendica\BaseEntity;
25 use Friendica\Util\DateTimeFormat;
28 * Class TrustedBrowser
31 * @property-read $cookie_hash
33 * @property-read $user_agent
34 * @property-read $trusted
35 * @property-read $created
36 * @property-read $last_used
37 * @package Friendica\Model\TwoFactor
39 class TrustedBrowser extends BaseEntity
41 protected $cookie_hash;
43 protected $user_agent;
49 * Please do not use this constructor directly, instead use one of the method of the TrustedBroser factory.
51 * @see \Friendica\Security\TwoFactor\Factory\TrustedBrowser
53 * @param string $cookie_hash
55 * @param string $user_agent
56 * @param bool $trusted
57 * @param string $created
58 * @param string|null $last_used
60 public function __construct(string $cookie_hash, int $uid, string $user_agent, bool $trusted, string $created, string $last_used = null)
62 $this->cookie_hash = $cookie_hash;
64 $this->user_agent = $user_agent;
65 $this->trusted = $trusted;
66 $this->created = $created;
67 $this->last_used = $last_used;
70 public function recordUse()
72 $this->last_used = DateTimeFormat::utcNow();