34 lines
764 B
PHP
34 lines
764 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Requests\StoreOTSRequest;
|
|
use App\Models\OneTimeSecret;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
class OTSController extends Controller
|
|
{
|
|
public function store(StoreOTSRequest $request): RedirectResponse
|
|
{
|
|
$validated = $request->validated();
|
|
|
|
OneTimeSecret::create(($validated + ['expires_at' => now()->addMinutes(30)]));
|
|
|
|
return back();
|
|
}
|
|
|
|
public function create(): Response
|
|
{
|
|
return Inertia::render('ots/Create');
|
|
}
|
|
|
|
public function show(OneTimeSecret $oneTimeSecret): Response
|
|
{
|
|
$oneTimeSecret->delete();
|
|
|
|
return Inertia::render('ots/Show', ['oneTimeSecret' => $oneTimeSecret]);
|
|
}
|
|
}
|