Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Controllers;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Auth;
- use Validator;
- use App\User;
- class IndexController extends Controller
- {
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function __construct()
- {
- $this->middleware('guest');
- }
- public function index()
- {
- return view('index');
- }
- public function checklogin(Request $request)
- {
- $this->validate($request, [
- 'email' => 'required|email',
- 'password' => 'required',
- ]);
- $user_data = array(
- 'email' => $request->input('email'),
- 'password' => $request->input('password'),
- );
- // if(Auth::attempt($user_data))
- // {
- // return redirect('dashboard/index')->with('success', 'Successful login, Welcome dear '.Auth::user()->name.'.');
- // }
- // else
- // {
- // return redirect()->route('index')->with('error', 'Your email or password is incorrect.');
- // }
- $code = $request->input('CaptchaCode');
- $isHuman = captcha_validate($code);
- if ($isHuman) {
- if(Auth::attempt($user_data))
- {
- return redirect('dashboard/index')->with('success', 'Successful login, Welcome dear '.Auth::user()->name.'.');
- }
- else
- {
- return redirect()->route('index')->with('error', 'Your email or password is incorrect.');
- }
- }
- else {
- return redirect()->route('index')->with('error', 'Invalid Captcha, Please try again.');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement