giftcon_dev/app/Models/AdminUser.php

46 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class AdminUser extends Authenticatable
{
use Notifiable;
protected $table = 'admin_users';
protected $hidden = [
'password',
'remember_token',
'phone_enc',
'totp_secret_enc',
];
protected $casts = [
'locked_until' => 'datetime',
'last_login_at' => 'datetime',
'password_changed_at' => 'datetime',
'totp_enabled' => 'boolean',
'totp_confirmed_at' => 'datetime',
'password' => 'hashed', // ✅ 이걸로 통일
'must_reset_password' => 'boolean',
'totp_enabled' => 'boolean',
'totp_verified_at' => 'datetime',
];
public function getTwoFactorModeAttribute(): string
{
$hasSecret = !empty($this->totp_secret_enc);
return ((int)($this->totp_enabled ?? 0) === 1 && $hasSecret) ? 'otp' : 'sms';
}
public function getTotpRegisteredAttribute(): bool
{
return !empty($this->totp_secret_enc);
}
}