30 lines
989 B
PHP
30 lines
989 B
PHP
<?php
|
|
|
|
namespace IriksIT\Manager\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use IriksIT\Manager\Support\Names;
|
|
|
|
/**
|
|
* The second step of one account (ADR-0016). `secret` and `recovery_codes` are encrypted with the app key; the recovery codes are
|
|
* kept as hashes, so a leaked table gives neither a code nor the secret. A row with no secret is an account that has to set it up
|
|
* but has not (or was reset): `required_since` keeps the start of its grace period.
|
|
*
|
|
* @property ?string $secret
|
|
* @property list<string>|null $recovery_codes
|
|
*/
|
|
class TwoFactor extends Model
|
|
{
|
|
protected $fillable = ['user_id', 'secret', 'recovery_codes', 'confirmed_at', 'last_step', 'required_since'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return ['secret' => 'encrypted', 'recovery_codes' => 'encrypted:array', 'confirmed_at' => 'datetime', 'required_since' => 'datetime'];
|
|
}
|
|
|
|
public function getTable(): string
|
|
{
|
|
return Names::table('two_factor');
|
|
}
|
|
}
|