mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-10 09:14:25 +02:00
Add trusted browser classes
- Added some tests
This commit is contained in:
parent
b633d75e6c
commit
72bb3bce34
7 changed files with 356 additions and 0 deletions
51
src/Security/TwoFactor/Model/TrustedBrowser.php
Normal file
51
src/Security/TwoFactor/Model/TrustedBrowser.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Security\TwoFactor\Model;
|
||||
|
||||
use Friendica\BaseEntity;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
||||
/**
|
||||
* Class TrustedBrowser
|
||||
*
|
||||
*
|
||||
* @property-read $cookie_hash
|
||||
* @property-read $uid
|
||||
* @property-read $user_agent
|
||||
* @property-read $created
|
||||
* @property-read $last_used
|
||||
* @package Friendica\Model\TwoFactor
|
||||
*/
|
||||
class TrustedBrowser extends BaseEntity
|
||||
{
|
||||
protected $cookie_hash;
|
||||
protected $uid;
|
||||
protected $user_agent;
|
||||
protected $created;
|
||||
protected $last_used;
|
||||
|
||||
/**
|
||||
* Please do not use this constructor directly, instead use one of the method of the TrustedBroser factory.
|
||||
*
|
||||
* @see \Friendica\Security\TwoFactor\Factory\TrustedBrowser
|
||||
*
|
||||
* @param string $cookie_hash
|
||||
* @param int $uid
|
||||
* @param string $user_agent
|
||||
* @param string $created
|
||||
* @param string|null $last_used
|
||||
*/
|
||||
public function __construct(string $cookie_hash, int $uid, string $user_agent, string $created, string $last_used = null)
|
||||
{
|
||||
$this->cookie_hash = $cookie_hash;
|
||||
$this->uid = $uid;
|
||||
$this->user_agent = $user_agent;
|
||||
$this->created = $created;
|
||||
$this->last_used = $last_used;
|
||||
}
|
||||
|
||||
public function recordUse()
|
||||
{
|
||||
$this->last_used = DateTimeFormat::utcNow();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue