98 - Testing the Login Endpoint

This commit is contained in:
Adam Wathan
2017-05-02 14:05:46 -04:00
parent 9d0fb299b8
commit 0bc8954774
3 changed files with 78 additions and 33 deletions

View File

@@ -3,37 +3,19 @@
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
public function login()
{
$this->middleware('guest', ['except' => 'logout']);
if (! Auth::attempt(request(['email', 'password']))) {
return redirect('/login')->withErrors([
'email' => ['These credentials do not match our records.'],
]);
}
return redirect('/backstage/concerts');
}
}