feat: implementation des dossiers candidats PDF, gestion des entretiens et optimisation de l'analyse IA
This commit is contained in:
@@ -90,12 +90,23 @@ class AttemptController extends Controller
|
||||
|
||||
public function saveAnswer(Request $request, Attempt $attempt)
|
||||
{
|
||||
// Security: Verify the authenticated user owns this attempt
|
||||
$candidate = auth()->user()->candidate;
|
||||
if (!$candidate || $attempt->candidate_id !== $candidate->id) {
|
||||
abort(403, 'You are not authorized to submit answers for this attempt.');
|
||||
}
|
||||
|
||||
$request->validate([
|
||||
'question_id' => 'required|exists:questions,id',
|
||||
'option_id' => 'nullable|exists:options,id',
|
||||
'text_content' => 'nullable|string',
|
||||
]);
|
||||
|
||||
// Extra guard: prevent answering a finished attempt
|
||||
if ($attempt->finished_at) {
|
||||
return response()->json(['error' => 'This attempt is already finished.'], 403);
|
||||
}
|
||||
|
||||
Answer::updateOrCreate(
|
||||
[
|
||||
'attempt_id' => $attempt->id,
|
||||
@@ -112,6 +123,12 @@ class AttemptController extends Controller
|
||||
|
||||
public function finish(Attempt $attempt)
|
||||
{
|
||||
// Security: Verify the authenticated user owns this attempt
|
||||
$candidate = auth()->user()->candidate;
|
||||
if (!$candidate || $attempt->candidate_id !== $candidate->id) {
|
||||
abort(403, 'You are not authorized to finish this attempt.');
|
||||
}
|
||||
|
||||
if ($attempt->finished_at) {
|
||||
return redirect()->route('dashboard');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user