Login page

This commit is contained in:
manavo
2014-11-24 17:21:50 +00:00
parent 66ddd7bd04
commit 2176e63ad9
3 changed files with 46 additions and 1 deletions

View File

@@ -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() {

View File

@@ -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');

View File

@@ -0,0 +1,35 @@
@extends('layout.master')
@section('content')
<div class='row'>
<div class='col-md-6 col-md-offset-3'>
{{ Form::open() }}
<fieldset>
<legend>Login</legend>
@if(Session::has('error'))
<span class='text-danger'>{{ Session::get('error') }}</span>
@endif
<div class='form-group'>
<label class='sr-only'>Email</label>
{{ Form::email('email', Input::old('email'), [
'class' => 'form-control', 'placeholder' => 'Email', 'required' => 'required'
]) }}
</div>
<div class='form-group'>
<label class='sr-only'>Password</label>
{{ Form::password('password', [
'class' => 'form-control', 'placeholder' => 'Password', 'required' => 'required'
]) }}
</div>
<div class='form-group'>
<button type='submit' class='btn btn-default'>Login!</button>
</div>
</fieldset>
{{ Form::close() }}
</div>
</div>
@stop