| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | namespace Aurora\Modules\TwoFactorAuth\Models; |
| 9: | |
| 10: | use Aurora\System\Classes\Model; |
| 11: | use Aurora\Modules\Core\Models\User; |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | class UsedDevice extends Model |
| 21: | { |
| 22: | protected $table = 'security_used_devices'; |
| 23: | protected $foreignModel = User::class; |
| 24: | protected $foreignModelIdColumn = 'UserId'; |
| 25: | |
| 26: | |
| 27: | protected $fillable = [ |
| 28: | 'Id', |
| 29: | 'UserId', |
| 30: | 'DeviceId', |
| 31: | 'DeviceName', |
| 32: | 'AuthToken', |
| 33: | 'CreationDateTime', |
| 34: | 'LastUsageDateTime', |
| 35: | 'TrustTillDateTime', |
| 36: | 'DeviceIP' |
| 37: | ]; |
| 38: | |
| 39: | public function toResponseArray() |
| 40: | { |
| 41: | $aResponse = parent::toResponseArray(); |
| 42: | $aResponse['Authenticated'] = false; |
| 43: | if (\Aurora\Api::GetSettings()->GetValue('StoreAuthTokenInDB', false) && !empty($aResponse['AuthToken']) && !empty(\Aurora\System\Api::UserSession()->Get($aResponse['AuthToken']))) { |
| 44: | $aResponse['Authenticated'] = true; |
| 45: | } |
| 46: | unset($aResponse['AuthToken']); |
| 47: | return $aResponse; |
| 48: | } |
| 49: | } |
| 50: | |