2020-07-22 10:58:25 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// {{{ License
|
|
|
|
|
|
|
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
|
|
|
//
|
|
|
|
// GNU social is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// GNU social is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
|
|
|
|
namespace App\Entity;
|
|
|
|
|
2020-08-15 15:18:23 +09:00
|
|
|
use App\Core\Entity;
|
2020-07-22 10:58:25 +09:00
|
|
|
use DateTimeInterface;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Entity for the remember_me token
|
|
|
|
*
|
|
|
|
* @category DB
|
|
|
|
* @package GNUsocial
|
|
|
|
*
|
2021-02-20 08:29:43 +09:00
|
|
|
* @author Hugo Sales <hugo@hsal.es>
|
|
|
|
* @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org
|
2020-07-22 10:58:25 +09:00
|
|
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
|
|
|
*/
|
2020-08-15 15:18:23 +09:00
|
|
|
class RememberMeToken extends Entity
|
2020-07-22 10:58:25 +09:00
|
|
|
{
|
|
|
|
// {{{ Autocode
|
2021-05-06 01:03:03 +09:00
|
|
|
// @codeCoverageIgnoreStart
|
2020-07-22 10:58:25 +09:00
|
|
|
private string $series;
|
|
|
|
private string $value;
|
2021-04-28 06:24:48 +09:00
|
|
|
private \DateTimeInterface $lastused;
|
2020-07-22 10:58:25 +09:00
|
|
|
private string $class;
|
|
|
|
private string $username;
|
|
|
|
|
|
|
|
public function setSeries(string $series): self
|
|
|
|
{
|
2021-12-27 00:12:06 +09:00
|
|
|
$this->series = \mb_substr($series, 0, 88);
|
2020-07-22 10:58:25 +09:00
|
|
|
return $this;
|
|
|
|
}
|
2020-08-09 01:11:18 +09:00
|
|
|
|
2020-07-22 10:58:25 +09:00
|
|
|
public function getSeries(): string
|
|
|
|
{
|
|
|
|
return $this->series;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setValue(string $value): self
|
|
|
|
{
|
2021-12-27 00:12:06 +09:00
|
|
|
$this->value = \mb_substr($value, 0, 88);
|
2020-07-22 10:58:25 +09:00
|
|
|
return $this;
|
|
|
|
}
|
2020-08-09 01:11:18 +09:00
|
|
|
|
2020-07-22 10:58:25 +09:00
|
|
|
public function getValue(): string
|
|
|
|
{
|
|
|
|
return $this->value;
|
|
|
|
}
|
|
|
|
|
2021-12-27 00:12:06 +09:00
|
|
|
public function setLastused(\DateTimeInterface $lastused): self
|
2020-07-22 10:58:25 +09:00
|
|
|
{
|
2021-01-03 00:52:05 +09:00
|
|
|
$this->lastused = $lastused;
|
2020-07-22 10:58:25 +09:00
|
|
|
return $this;
|
|
|
|
}
|
2020-08-09 01:11:18 +09:00
|
|
|
|
2021-12-27 00:12:06 +09:00
|
|
|
public function getLastused(): \DateTimeInterface
|
2020-07-22 10:58:25 +09:00
|
|
|
{
|
2021-01-03 00:52:05 +09:00
|
|
|
return $this->lastused;
|
2020-07-22 10:58:25 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setClass(string $class): self
|
|
|
|
{
|
2021-12-27 00:12:06 +09:00
|
|
|
$this->class = \mb_substr($class, 0, 100);
|
2020-07-22 10:58:25 +09:00
|
|
|
return $this;
|
|
|
|
}
|
2020-08-09 01:11:18 +09:00
|
|
|
|
2020-07-22 10:58:25 +09:00
|
|
|
public function getClass(): string
|
|
|
|
{
|
|
|
|
return $this->class;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setUsername(string $username): self
|
|
|
|
{
|
2021-12-27 00:12:06 +09:00
|
|
|
$this->username = \mb_substr($username, 0, 64);
|
2020-07-22 10:58:25 +09:00
|
|
|
return $this;
|
|
|
|
}
|
2020-08-09 01:11:18 +09:00
|
|
|
|
2020-07-22 10:58:25 +09:00
|
|
|
public function getUsername(): string
|
|
|
|
{
|
|
|
|
return $this->username;
|
|
|
|
}
|
|
|
|
|
2021-05-06 01:03:03 +09:00
|
|
|
// @codeCoverageIgnoreEnd
|
2020-07-22 10:58:25 +09:00
|
|
|
// }}} Autocode
|
|
|
|
|
|
|
|
public static function schemaDef(): array
|
|
|
|
{
|
|
|
|
$def = [
|
|
|
|
'name' => 'rememberme_token',
|
|
|
|
'fields' => [
|
|
|
|
'series' => ['type' => 'char', 'length' => 88, 'not null' => true],
|
|
|
|
'value' => ['type' => 'char', 'length' => 88, 'not null' => true],
|
2021-01-03 00:52:05 +09:00
|
|
|
'lastused' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP'],
|
2020-07-22 10:58:25 +09:00
|
|
|
'class' => ['type' => 'varchar', 'length' => 100, 'not null' => true],
|
|
|
|
'username' => ['type' => 'varchar', 'length' => 64, 'not null' => true],
|
|
|
|
],
|
|
|
|
'primary key' => ['series'],
|
|
|
|
];
|
|
|
|
|
|
|
|
return $def;
|
|
|
|
}
|
|
|
|
}
|