I get an error when using google reCaptcha. When installing reCaptcha there is no problem. But when I enter it into validation, an error like this occurs.
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'g-recaptcha-response' in 'where clause'
screen_login_form
screen_error
screen_login_view
screen_login_controller
my view (u_login.blade.php):
<form method="POST" action="/login/cek" >
@csrf
<div>
<h1 >LOGIN</h1>
@error('g-recaptcha-response')
<label ><small>Login gagal.</small></label>
enderror
</div>
<div >
<input name="email" type="email" placeholder="Email" autofocus required>
</div>
<div >
<input type="password" name="password" placeholder="Password" required>
</div>
<div >
{!! NoCaptcha::renderJs('id', false, 'recaptchaCallback') !!}
{!! NoCaptcha::display() !!}
</div>
<button type="submit" name="masuk" name="logout">Masuk</button>
<div >
<p> Belum punya akun? <a href="/register">Daftar di sini</a></p>
</div>
</form>
my controller (u_auth.php):
public function authenticate(Request $request)
{
$credentials = $request->validate([
'email' => 'required|email:rfc,dns',
'password' => 'required',
'g-recaptcha-response' => 'required|captcha'
]);
// JIKA LOGIN BERHASIL
if (Auth::attempt($credentials)) {
$request->session()->regenerate();
//dd($credentials);
return redirect()->intended('')->withToastSuccess('Berhasil masuk!');
}
// JIKA LOGIN GAGAL
return back()->with('toast_error', 'Login gagal!');
}
please help me solve this problem with your best solution.
CodePudding user response:
In Auth::attempt() we have to pass user's creadentials.
In this case, you are passing captcha along with credentials, so you are getting error
If you pass only credentials with out captcha in attempt method than you will not getting any error
I hope it will work