//GET IP if (!empty($_SERVER['HTTP_CLIENT_IP'])) $remoteip = $_SERVER['HTTP_CLIENT_IP']; elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) $remoteip = $_SERVER['HTTP_X_FORWARDED_FOR']; else $remoteip = $_SERVER['REMOTE_ADDR']; //Request API $recaptcha_api = $recaptcha_api . '?secret=' . $secret_key . '&response=' . $captcha . '&remoteip=' . $remoteip; //GET result API $response = file_get_contents($recaptcha_api); //Decode $response = json_decode($response); if (isset($response->success) && $response->success == true) { /** This line should be in the start of method */ if ($this->hasTooManyLoginAttempts($request)) { $this->fireLockoutEvent($request); return $this->sendLockoutResponse($request); } $remember = (Input::has('remember')) ? true : false; $credentials = [ 'email' => $request->email, 'password' => $request->password, 'status' => 1 ]; if (Auth::attempt($credentials, $remember)) { $this->clearLoginAttempts($request); $user = Auth::user(); $notification = ['flag' => 'success', 'message' => 'Welcome back, ' . mb_strtoupper($user->nicename, 'UTF-8')]; return redirect('my-account')->with($notification); } else { $this->incrementLoginAttempts($request); $notification = ['flag' => 'error', 'message' => 'Please check again, maybe:
-Email\Password is incorrect
-Email is locked']; return redirect()->back()->with($notification)->withInput(); } } else { $notification = ['flag' => 'error', 'message' => 'Could not verify you. Please try again!']; return redirect()->back()->with($notification)->withInput(); } } else { $notification = ['flag' => 'error', 'message' => 'Could not verify you. Please try again!']; return redirect()->back()->with($notification)->withInput(); } } public function logout() { if (Auth::check()) Auth::logout(); return redirect()->route('account.getLogin'); } }