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/controllers/SetupController.php b/app/controllers/SetupController.php index 62a85ee3..d2bf4c21 100644 --- a/app/controllers/SetupController.php +++ b/app/controllers/SetupController.php @@ -26,7 +26,7 @@ $user = new User; $user->username = $userDetails['name']; $user->email = $userDetails['email']; - $user->password = $userDetails['password']; + $user->password = Hash::make($userDetails['password']); $user->save(); Auth::login($user); diff --git a/app/routes/app.php b/app/routes/app.php index f6afbb08..bf8d6f5b 100644 --- a/app/routes/app.php +++ b/app/routes/app.php @@ -10,7 +10,9 @@ }); }); - Route::get('/auth/login', 'AuthController@showLogin'); + 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 diff --git a/app/views/index.blade.php b/app/views/index.blade.php index 9018f394..0e12f0ac 100644 --- a/app/views/index.blade.php +++ b/app/views/index.blade.php @@ -25,7 +25,7 @@ @if(Setting::get('show_support'))
@endif @stop