Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login functionality, and some small things #18

Merged
merged 4 commits into from
Nov 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/SetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function setupCachet() {
$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);
Expand Down
4 changes: 3 additions & 1 deletion app/routes/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
35 changes: 35 additions & 0 deletions app/views/auth/login.blade.php
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion app/views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@if(Setting::get('show_support'))
<hr />
<div class='footer'>
<p>{{ Setting::get('app_name') }} Status Page is powered by <a href='https://github.com/jbrooksuk/Cachet'>Cachet</a>.</p>
<p>{{ Setting::get('app_name') }} Status Page is powered by <a href='https://github.com/jbrooksuk/Cachet' target="_blank">Cachet</a>.</p>
</div>
@endif
@stop