mirror of
https://github.com/friendica/friendica
synced 2025-04-27 02:30:10 +00: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
33
src/Security/TwoFactor/Factory/TrustedBrowser.php
Normal file
33
src/Security/TwoFactor/Factory/TrustedBrowser.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Security\TwoFactor\Factory;
|
||||
|
||||
use Friendica\BaseFactory;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
class TrustedBrowser extends BaseFactory
|
||||
{
|
||||
public function createForUserWithUserAgent($uid, $userAgent): \Friendica\Security\TwoFactor\Model\TrustedBrowser
|
||||
{
|
||||
$trustedHash = Strings::getRandomHex();
|
||||
|
||||
return new \Friendica\Security\TwoFactor\Model\TrustedBrowser(
|
||||
$trustedHash,
|
||||
$uid,
|
||||
$userAgent,
|
||||
DateTimeFormat::utcNow()
|
||||
);
|
||||
}
|
||||
|
||||
public function createFromTableRow(array $row): \Friendica\Security\TwoFactor\Model\TrustedBrowser
|
||||
{
|
||||
return new \Friendica\Security\TwoFactor\Model\TrustedBrowser(
|
||||
$row['cookie_hash'],
|
||||
$row['uid'],
|
||||
$row['user_agent'],
|
||||
$row['created'],
|
||||
$row['last_used']
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue