Üye girişi yaparken böyle bir hata alıyorum.Sayfayı yenilediğimde üye girişi yapmış oluyor. Sizce sorun nereden kaynaklanıyor olabilir ?
TypeError
Argument 1 passed to Illuminate\Auth\SessionGuard::login() must implement interface Illuminate\Contracts\Auth\Authenticatable, instance of App\Models\UserAuth given, called in C:\Users\pc1\Desktop\proje\vendor\laravel\framework\src\Illuminate\Auth\AuthManager.php on line 336
http://127.0.0.1:8000/user/userAuthCheck
UserAuthCheck middleware
class UserAuthCheck
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if (Auth::check() != true && ($request->path() != 'user/login' && $request->path() != 'user/register')) {
return redirect()->route('userLogin')->with('errorLogin', 'You must be logged in');
}
if (Auth::check() == true && ($request->path() == 'user/login' or $request->path() == 'user/register')) {
return redirect()->route('homepage');
}
return $next($request)->header('Cache-Control', 'nocache, no-store, max-age=0, must-revalidate')->header('Pragma', 'no-cache')->header('Expires', 'Fri, 01 Jan 1990 00:00:00 GMT');
}
}
Login Controller
` public function userAuthCheck(Request $request)
{
$validator = Validator::make($request->all(), [
'email' => 'required|string|email|max:255',
'password' => 'required|string|min:6',
'g-recaptcha-response' => function ($attribute, $value, $fail) {
$response = $value;
$userIP = $_SERVER['REMOTE_ADDR'];
$url = "https://www.google.com/recaptcha/api/siteverify?secret=" . config('services.googlerecaptcha.secret') . "&response=" . $response . "&remoteip=" . $userIP;
$response = file_get_contents($url);
$response = json_decode($response);
if (!$response->success) {
$fail($attribute . ' is not a valid captcha');
return redirect()->back()->with('failcaptcha', 'Please check the captcha');
}
},
]);
if ($validator->fails()) {
return redirect()->back()->withErrors($validator)->withInput();
}
$user = UserAuth::where('email', $request->email)->first();
if (!$user) {
return redirect()->back()->with('fail', 'Email or Password is incorrect');
} else {
if (Hash::check($request->password, $user->password)) {
if ($request->remember == 'on') {
$remember = true;
} else {
$remember = false;
}
if (Auth::attempt(['email' => $request->email, 'password' => $request->password], $remember)) {
Auth::login($user, true);
return redirect()->route('homepage');
}
} else {
return redirect()->back()->with('fail', 'Email or password is incorrect');
}
}
}`