implement captcha system
This commit is contained in:
parent
a42b9967d9
commit
dad10fc532
@ -8,6 +8,7 @@ use App\Models\DeviceSession;
|
||||
use App\Http\Requests\LoginRequest;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
@ -23,6 +24,19 @@ class LoginController extends Controller
|
||||
|
||||
$remember = $request->has('remember');
|
||||
|
||||
//captcha
|
||||
$response = Http::asForm()->post('https://hcaptcha.com/siteverify', [
|
||||
'secret' => 'ES_f05ab02ddc424bbabca7e82b79f1c09f',
|
||||
'response' => $request->input('h-captcha-response'),
|
||||
'remoteip' => $request->ip(),
|
||||
]);
|
||||
|
||||
$verification = $response->json();
|
||||
|
||||
if (!isset($verification['success']) || $verification['success'] !== true) {
|
||||
return back()->withErrors(['error' => 'captcha is not correct']);
|
||||
}
|
||||
|
||||
if (!Auth::attempt($credentials, $remember)) {
|
||||
return back()->withErrors([
|
||||
'email' => 'The provided credentials do not match our records.',
|
||||
|
||||
@ -24,6 +24,7 @@ class LoginRequest extends FormRequest
|
||||
return [
|
||||
'email' => 'required|email',
|
||||
'password' => 'required|min:8',
|
||||
'h-captcha-response' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,6 +45,7 @@
|
||||
{{ $message }}
|
||||
@enderror
|
||||
</p>
|
||||
{{-- captcha scction --}}
|
||||
<div class="mt-8">
|
||||
<button type="submit"
|
||||
class="border border-[#e0e1dd] font-medium w-full p-2 rounded-md bg-[#e0e1dd] cursor-pointer hover:opacity-85 transition duration-300 ease-in-out text-black">Login</button>
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
|
||||
<body>
|
||||
@yield('content')
|
||||
<script src="https://js.hcaptcha.com/1/api.js" async defer></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user