function verify($id_entry, Request $req, $crpt_pass) { $vld = Validator::make(['id' => $id_entry, 'password' => $req->input('password'), 'crpt' => $crpt_pass], ['id' => 'required|numeric', 'password' => 'required_without:crpt', 'crpt' => 'required_without:password']); if ($vld->fails()) { if ($req->is('light/*')) { if (!empty($crpt_pass)) { return redirect('light')->with('message', 'Lien erroné.'); } return redirect()->back()->with('errors', $vld->messages()->all()); } return response()->json($vld->messages()->all(), 400); } $id_game = $req->input('id_game'); $password = empty($crpt_pass) ? $req->input('password') : Crypt::decrypt($crpt_pass); if (Entry::approve($id_entry, $password) > 0) { if ($req->is('light/*')) { return redirect('/')->with('message', 'Entrée confirmée.'); } else { return response()->json("success"); } } if ($req->is('light/*')) { if (!empty($crpt_pass)) { return redirect('light')->with('message', 'Lien erroné.'); } return redirect()->back()->with('errors', ["Mot de passe non valide."]); } return response()->json("Mot de passe non valide."); }