diff --git a/app/controllers/AuthController.php b/app/controllers/AuthController.php index 31efa39a..dae85ffa 100644 --- a/app/controllers/AuthController.php +++ b/app/controllers/AuthController.php @@ -5,7 +5,15 @@ */ class AuthController extends Controller { public function showLogin() { - return 'Coming soon...'; + return View::make('auth.login'); + } + + public function postLogin() { + if (Auth::attempt(Input::only(['email', 'password']))) { + return Redirect::intended('dashboard'); + } else { + return Redirect::back()->withInput(Input::except('password'))->with('error', 'Invalid email or password'); + } } public function logoutAction() { diff --git a/app/routes/app.php b/app/routes/app.php index 3376b44b..bf8d6f5b 100644 --- a/app/routes/app.php +++ b/app/routes/app.php @@ -11,6 +11,8 @@ }); Route::get('/auth/login', 'AuthController@showLogin')->before('guest'); + Route::post('/auth/login', 'AuthController@postLogin')->before('guest|csrf'); + Route::group(['before' => 'auth'], function() { // Dashboard/Management Panel etc. Route::get('/dashboard', 'DashboardController@showDashboard'); diff --git a/app/views/auth/login.blade.php b/app/views/auth/login.blade.php new file mode 100644 index 00000000..bf6088da --- /dev/null +++ b/app/views/auth/login.blade.php @@ -0,0 +1,35 @@ +@extends('layout.master') + +@section('content') + +
+
+ {{ Form::open() }} +
+ Login + + @if(Session::has('error')) + {{ Session::get('error') }} + @endif + +
+ + {{ Form::email('email', Input::old('email'), [ + 'class' => 'form-control', 'placeholder' => 'Email', 'required' => 'required' + ]) }} +
+
+ + {{ Form::password('password', [ + 'class' => 'form-control', 'placeholder' => 'Password', 'required' => 'required' + ]) }} +
+
+ +
+
+ {{ Form::close() }} +
+
+ +@stop