2016-02-29 15:59:36 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
2016-03-05 00:18:10 +00:00
|
|
|
use Auth;
|
|
|
|
|
use Illuminate\Contracts\Auth\Guard;
|
|
|
|
|
use Input;
|
|
|
|
|
use Redirect;
|
|
|
|
|
use Request;
|
|
|
|
|
use View;
|
|
|
|
|
|
|
|
|
|
class UserLoginController extends Controller
|
|
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
protected $auth;
|
|
|
|
|
|
2016-03-05 00:18:10 +00:00
|
|
|
public function __construct(Guard $auth)
|
|
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
$this->auth = $auth;
|
|
|
|
|
$this->middleware('guest');
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-05 00:18:10 +00:00
|
|
|
public function showLogin()
|
|
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* If there's an ajax request to the login page assume the person has been
|
|
|
|
|
* logged out and redirect them to the login page
|
|
|
|
|
*/
|
|
|
|
|
if (Request::ajax()) {
|
2016-03-05 00:18:10 +00:00
|
|
|
return Response::json([
|
|
|
|
|
'status' => 'success',
|
|
|
|
|
'redirectUrl' => route('login'),
|
|
|
|
|
]);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return View::make('Public.LoginAndRegister.Login');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2016-03-05 00:18:10 +00:00
|
|
|
* Handle the login.
|
|
|
|
|
*
|
2016-02-29 15:59:36 +00:00
|
|
|
* @return void
|
|
|
|
|
*/
|
2016-03-05 00:18:10 +00:00
|
|
|
public function postLogin()
|
|
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
$email = Input::get('email');
|
|
|
|
|
$password = Input::get('password');
|
|
|
|
|
|
2016-03-05 00:18:10 +00:00
|
|
|
if ($this->auth->attempt(['email' => $email, 'password' => $password], true)) {
|
2016-02-29 15:59:36 +00:00
|
|
|
return Redirect::to(route('showSelectOrganiser'));
|
|
|
|
|
}
|
2016-03-05 00:18:10 +00:00
|
|
|
|
2016-02-29 15:59:36 +00:00
|
|
|
return Redirect::to('login?failed=yup')->with('message', 'Your username/password combination was incorrect')
|
|
|
|
|
->withInput();
|
|
|
|
|
}
|
|
|
|
|
}
|