dyndns/app/Http/Controllers/DynDnsController.php

35 lines
942 B
PHP
Raw Permalink Normal View History

2019-08-10 14:34:53 +00:00
<?php
namespace App\Http\Controllers;
use APP\Component\Config\IConfig;
use App\Jobs\Updater\IUpdater;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class DynDnsController extends Controller
{
public function update(Request $request) {
$this->validate($request, [
'hostname' => 'required',
'myip' => 'required|ipv4',
'password' => 'required|',
'username' => 'required|'
]);
$config = app(IConfig::class);
$updater = app(IUpdater::class);
$userValide = $config->validateUser($request->input("username"), $request->input("password"), $request->input("hostname"));
if(!$userValide) {
return new Response("Invalide Data", 400);
}
$updater->config($request->input("hostname"), $request->input("myip"));
$this->dispatch($updater);
return new Response("Update started", 201);
}
}