From 2176e63ad95c1e0682e8188f6fb00833b7342993 Mon Sep 17 00:00:00 2001 From: manavo Date: Mon, 24 Nov 2014 17:21:50 +0000 Subject: [PATCH] Login page --- app/controllers/AuthController.php | 10 ++++++++- app/routes/app.php | 2 ++ app/views/auth/login.blade.php | 35 ++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 app/views/auth/login.blade.php 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