Fixed user login and authentication.

This commit is contained in:
James Cole 2015-02-27 16:08:46 +01:00
parent 75aa3abcae
commit aca096548c
10 changed files with 183 additions and 179 deletions

View File

@ -148,7 +148,7 @@ class ReportHelper implements ReportHelperInterface
$sharedAccounts[] = $account->id;
}
$accounts = \Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->get()->filter(
$accounts = \Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->get(['accounts.*'])->filter(
function (Account $account) use ($sharedAccounts) {
if (!in_array($account->id, $sharedAccounts)) {
return $account;

View File

@ -26,6 +26,9 @@ class PasswordController extends Controller
use ResetsPasswords;
protected $redirectPath = '/';
/**
* Create a new password controller instance.
*
@ -38,6 +41,7 @@ class PasswordController extends Controller
$this->auth = $auth;
$this->passwords = $passwords;
$this->middleware('guest');
}

View File

@ -41,7 +41,7 @@ class RedirectIfAuthenticated
public function handle($request, Closure $next)
{
if ($this->auth->check()) {
return new RedirectResponse(url('/home'));
return new RedirectResponse(url('/'));
}
return $next($request);

View File

@ -127,12 +127,27 @@ Route::bind(
}
);
/**
* Auth\AuthController
*/
Route::get('/register', ['uses' => 'Auth\AuthController@getRegister', 'as' => 'register']);
Route::controllers(
[
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]
);
/**
* Home Controller
*/
Route::group(
['middleware' => ['auth', 'range']], function () {
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']);
Route::get('/home', ['uses' => 'HomeController@index', 'as' => 'home']);
Route::get('/prev', ['uses' => 'HomeController@sessionPrev', 'as' => 'sessionPrev']);
Route::get('/next', ['uses' => 'HomeController@sessionNext', 'as' => 'sessionNext']);
Route::get('/jump/{range}', ['uses' => 'HomeController@rangeJump', 'as' => 'rangeJump']);
@ -327,14 +342,3 @@ Route::group(
}
);
/**
* Auth\AuthController
*/
Route::get('/register', ['uses' => 'Auth\AuthController@getRegister', 'as' => 'register']);
Route::controllers(
[
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]
);

View File

@ -24,7 +24,7 @@ class Registrar implements RegistrarContract
return User::create(
[
'email' => $data['email'],
'password' => bcrypt($data['password']),
'password' => $data['password'],
]
);
}

View File

@ -28,7 +28,7 @@ return [
|
*/
'host' => 'smtp.mailgun.org',
'host' => env('EMAIL_SMTP', 'smtp.mailgun.org'),
/*
|--------------------------------------------------------------------------
@ -54,7 +54,7 @@ return [
|
*/
'from' => ['address' => null, 'name' => null],
'from' => ['address' => env('EMAIL_USERNAME', null), 'name' => 'Firefly III Mailer'],
/*
|--------------------------------------------------------------------------
@ -80,7 +80,7 @@ return [
|
*/
'username' => null,
'username' => env('EMAIL_USERNAME', null),
/*
|--------------------------------------------------------------------------
@ -93,7 +93,7 @@ return [
|
*/
'password' => null,
'password' => env('EMAIL_PASSWORD', null),
/*
|--------------------------------------------------------------------------

View File

@ -20,15 +20,19 @@
<h3 class="panel-title">Firefly III &mdash; Sign In</h3>
</div>
<div class="panel-body">
<form role="form" method="POST" id="login" action="/auth/login">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="form-group">
<input type="email" class="form-control" id="inputEmail" name="email" placeholder="E-mail">
<label class="control-label">E-Mail</label>
<input type="email" class="form-control" id="inputEmail" name="email" placeholder="E-Mail">
</div>
<div class="form-group">
<label class="control-label">Password</label>
<input type="password" class="form-control" id="inputPassword" name="password" placeholder="Password">
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="remember" value="1"> Remember me

View File

@ -1,11 +1,12 @@
@extends('app')
@extends('layouts.guest')
@section('content')
<div class="container-fluid">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Reset Password</div>
<div class="col-md-4 col-md-offset-4">
<div class="login-panel panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Firefly III &mdash; Reset Password</h3>
</div>
<div class="panel-body">
@if (session('status'))
<div class="alert alert-success">
@ -24,23 +25,17 @@
</div>
@endif
<form class="form-horizontal" role="form" method="POST" action="/password/email">
<form role="form" method="POST" action="/password/email">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="form-group">
<label class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input type="email" class="form-control" name="email" value="{{ old('email') }}">
</div>
<label class="control-label">E-Mail</label>
<input type="email" class="form-control" placeholder="E-Mail" name="email" value="{{ old('email') }}">
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Send Password Reset Link
</button>
</div>
</div>
<p>
<button type="submit" class="btn btn-lg btn-success btn-block">Send Password Reset</button>
</p>
</form>
</div>
</div>

View File

@ -4,7 +4,9 @@
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class="login-panel panel panel-default">
<div class="panel-heading">Firefly III &mdash; Register</div>
<div class="panel-heading">
<h3 class="panel-title">Firefly III &mdash; Register</h3>
</div>
<div class="panel-body">
<p>
Registering an account on Firefly requires an e-mail address.
@ -24,27 +26,30 @@
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="form-group">
<label class="control-label">E-Mail Address</label>
<input type="email" class="form-control" name="email" value="{{ old('email') }}">
<label class="control-label">E-Mail</label>
<input type="email" class="form-control" placeholder="E-Mail" name="email" value="{{ old('email') }}">
</div>
<div class="form-group">
<label class="control-label">Password</label>
<input type="password" class="form-control" name="password">
<input type="password" placeholder="Password" class="form-control" name="password">
</div>
<div class="form-group">
<label class="control-label">Confirm Password</label>
<input type="password" class="form-control" name="password_confirmation">
<input type="password" placeholder="Confirm Password" class="form-control" name="password_confirmation">
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Register
</button>
</div>
<p>
<button type="submit" class="btn btn-lg btn-success btn-block">Register</button>
</p>
<div class="btn-group btn-group-justified btn-group-sm">
<a href="/auth/login" class="btn btn-default">Login</a>
<a href="/password/email" class="btn btn-default">Forgot your password?</a>
</div>
</form>
</div>
</div>

View File

@ -1,11 +1,11 @@
@extends('app')
@extends('layouts.guest')
@section('content')
<div class="container-fluid">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Reset Password</div>
<div class="col-md-4 col-md-offset-4">
<div class="login-panel panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Firefly III &mdash; Reset Password</h3>
</div>
<div class="panel-body">
@if (count($errors) > 0)
<div class="alert alert-danger">
@ -18,38 +18,30 @@
</div>
@endif
<form class="form-horizontal" role="form" method="POST" action="/password/reset">
<form role="form" method="POST" action="/password/reset">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="hidden" name="token" value="{{ $token }}">
<div class="form-group">
<label class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input type="email" class="form-control" name="email" value="{{ old('email') }}">
</div>
<label id="email" class="control-label">E-Mail</label>
<input type="email" class="form-control" placeholder="E-Mail" name="email" value="{{ old('email') }}">
</div>
<div class="form-group">
<label class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input type="password" class="form-control" name="password">
</div>
<label class="control-label">Password</label>
<input type="password" placeholder="Password" class="form-control" name="password">
</div>
<div class="form-group">
<label class="col-md-4 control-label">Confirm Password</label>
<div class="col-md-6">
<input type="password" class="form-control" name="password_confirmation">
</div>
<label class="control-label">Confirm Password</label>
<input type="password" placeholder="Confirm Password" class="form-control" name="password_confirmation">
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
<button type="submit" class="btn btn-success btn-lg btn-block">
Reset Password
</button>
</div>
</div>
</form>
</div>
</div>