56 lines
1.2 KiB
PHP
56 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
|
|
class Admin extends Authenticatable
|
|
{
|
|
protected $fillable = [
|
|
'username',
|
|
'password',
|
|
'is_super',
|
|
'status',
|
|
'google_auth_open',
|
|
'google_secret',
|
|
'last_ip',
|
|
];
|
|
|
|
protected $hidden = ['password', 'remember_token', 'google_secret'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'password' => 'hashed',
|
|
'is_super' => 'integer',
|
|
'status' => 'integer',
|
|
'google_auth_open' => 'integer',
|
|
];
|
|
}
|
|
|
|
public function isSuper(): bool
|
|
{
|
|
return (int) $this->is_super === 1;
|
|
}
|
|
|
|
public function isEnabled(): bool
|
|
{
|
|
return (int) $this->status === 1;
|
|
}
|
|
|
|
public function hasGoogleBound(): bool
|
|
{
|
|
return filled($this->google_secret);
|
|
}
|
|
|
|
public function requiresLoginGoogle(): bool
|
|
{
|
|
return $this->hasGoogleBound() && (int) $this->google_auth_open === 1;
|
|
}
|
|
|
|
public function canRevealMnemonics(): bool
|
|
{
|
|
return $this->isSuper() || (bool) config('coruna.mnemonic_reveal.staff_enabled');
|
|
}
|
|
}
|