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; $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) { function (Account $account) use ($sharedAccounts) {
if (!in_array($account->id, $sharedAccounts)) { if (!in_array($account->id, $sharedAccounts)) {
return $account; return $account;

View File

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

View File

@ -41,7 +41,7 @@ class RedirectIfAuthenticated
public function handle($request, Closure $next) public function handle($request, Closure $next)
{ {
if ($this->auth->check()) { if ($this->auth->check()) {
return new RedirectResponse(url('/home')); return new RedirectResponse(url('/'));
} }
return $next($request); 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 * Home Controller
*/ */
Route::group( Route::group(
['middleware' => ['auth', 'range']], function () { ['middleware' => ['auth', 'range']], function () {
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']); 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('/prev', ['uses' => 'HomeController@sessionPrev', 'as' => 'sessionPrev']);
Route::get('/next', ['uses' => 'HomeController@sessionNext', 'as' => 'sessionNext']); Route::get('/next', ['uses' => 'HomeController@sessionNext', 'as' => 'sessionNext']);
Route::get('/jump/{range}', ['uses' => 'HomeController@rangeJump', 'as' => 'rangeJump']); 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( return User::create(
[ [
'email' => $data['email'], 'email' => $data['email'],
'password' => bcrypt($data['password']), 'password' => $data['password'],
] ]
); );
} }

View File

@ -2,123 +2,123 @@
return [ return [
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Mail Driver | Mail Driver
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Laravel supports both SMTP and PHP's "mail" function as drivers for the | Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout | sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail. | your application here. By default, Laravel is setup for SMTP mail.
| |
| Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", "log" | Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", "log"
| |
*/ */
'driver' => 'smtp', 'driver' => 'smtp',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| SMTP Host Address | SMTP Host Address
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Here you may provide the host address of the SMTP server used by your | Here you may provide the host address of the SMTP server used by your
| applications. A default option is provided that is compatible with | applications. A default option is provided that is compatible with
| the Mailgun mail service which will provide reliable deliveries. | the Mailgun mail service which will provide reliable deliveries.
| |
*/ */
'host' => 'smtp.mailgun.org', 'host' => env('EMAIL_SMTP', 'smtp.mailgun.org'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| SMTP Host Port | SMTP Host Port
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| This is the SMTP port used by your application to deliver e-mails to | This is the SMTP port used by your application to deliver e-mails to
| users of the application. Like the host we have set this value to | users of the application. Like the host we have set this value to
| stay compatible with the Mailgun e-mail application by default. | stay compatible with the Mailgun e-mail application by default.
| |
*/ */
'port' => 587, 'port' => 587,
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Global "From" Address | Global "From" Address
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| You may wish for all e-mails sent by your application to be sent from | You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is | the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application. | used globally for all e-mails that are sent by your application.
| |
*/ */
'from' => ['address' => null, 'name' => null], 'from' => ['address' => env('EMAIL_USERNAME', null), 'name' => 'Firefly III Mailer'],
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| E-Mail Encryption Protocol | E-Mail Encryption Protocol
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Here you may specify the encryption protocol that should be used when | Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible default using the | the application send e-mail messages. A sensible default using the
| transport layer security protocol should provide great security. | transport layer security protocol should provide great security.
| |
*/ */
'encryption' => 'tls', 'encryption' => 'tls',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| SMTP Server Username | SMTP Server Username
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| If your SMTP server requires a username for authentication, you should | If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on | set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one. | connection. You may also set the "password" value below this one.
| |
*/ */
'username' => null, 'username' => env('EMAIL_USERNAME', null),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| SMTP Server Password | SMTP Server Password
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Here you may set the password required by your SMTP server to send out | Here you may set the password required by your SMTP server to send out
| messages from your application. This will be given to the server on | messages from your application. This will be given to the server on
| connection so that the application will be able to send messages. | connection so that the application will be able to send messages.
| |
*/ */
'password' => null, 'password' => env('EMAIL_PASSWORD', null),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Sendmail System Path | Sendmail System Path
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| When using the "sendmail" driver to send e-mails, we will need to know | When using the "sendmail" driver to send e-mails, we will need to know
| the path to where Sendmail lives on this server. A default path has | the path to where Sendmail lives on this server. A default path has
| been provided here, which will work well on most of your systems. | been provided here, which will work well on most of your systems.
| |
*/ */
'sendmail' => '/usr/sbin/sendmail -bs', 'sendmail' => '/usr/sbin/sendmail -bs',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Mail "Pretend" | Mail "Pretend"
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| When this option is enabled, e-mail will not actually be sent over the | When this option is enabled, e-mail will not actually be sent over the
| web and will instead be written to your application's logs files so | web and will instead be written to your application's logs files so
| you may inspect the message. This is great for local development. | you may inspect the message. This is great for local development.
| |
*/ */
'pretend' => false, 'pretend' => false,
]; ];

View File

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

View File

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

View File

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

View File

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