added created view and confirm show
This commit is contained in:
@@ -4,30 +4,54 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\StoreOTSRequest;
|
||||
use App\Models\OneTimeSecret;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class OTSController extends Controller
|
||||
{
|
||||
public function created(Request $request)
|
||||
{
|
||||
$link = $request->session()->get('otsLink');
|
||||
$request->session()->remove('otsLink');
|
||||
if (! $link) {
|
||||
return redirect()->route('ots.create');
|
||||
}
|
||||
|
||||
return Inertia::render('ots/Created', [
|
||||
'otsLink' => $link,
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(StoreOTSRequest $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validated();
|
||||
|
||||
OneTimeSecret::create(($validated + ['expires_at' => now()->addMinutes(30)]));
|
||||
$ots = OneTimeSecret::create(($validated + ['expires_at' => now()->addMinutes(30)]));
|
||||
$otsLink = route('ots.show', ['oneTimeSecret' => $ots->id]);
|
||||
|
||||
return back();
|
||||
return redirect()->route('ots.created')->with(['otsLink' => $otsLink]);
|
||||
}
|
||||
|
||||
public function create(): Response
|
||||
{
|
||||
return Inertia::render('ots/Create');
|
||||
return Inertia::render('ots/Create', []);
|
||||
}
|
||||
|
||||
public function show(OneTimeSecret $oneTimeSecret): Response
|
||||
{
|
||||
$oneTimeSecret->delete();
|
||||
return Inertia::render('ots/Show', ['oneTimeSecretId' => $oneTimeSecret->id]);
|
||||
}
|
||||
|
||||
return Inertia::render('ots/Show', ['oneTimeSecret' => $oneTimeSecret]);
|
||||
public function reveal(OneTimeSecret $oneTimeSecret): JsonResponse
|
||||
{
|
||||
$oneTimeSecret->delete();
|
||||
if ($oneTimeSecret->expires_at->isPast()) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
return response()->json(['secret' => $oneTimeSecret->secret]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ class TeamController extends Controller
|
||||
|
||||
public function create(): Response
|
||||
{
|
||||
return Inertia::render('team/Create');
|
||||
return Inertia::render('team/Create', []);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user