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

@ -2,123 +2,123 @@
return [
/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| 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
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", "log"
|
*/
/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| 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
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", "log"
|
*/
'driver' => 'smtp',
'driver' => 'smtp',
/*
|--------------------------------------------------------------------------
| SMTP Host Address
|--------------------------------------------------------------------------
|
| Here you may provide the host address of the SMTP server used by your
| applications. A default option is provided that is compatible with
| the Mailgun mail service which will provide reliable deliveries.
|
*/
/*
|--------------------------------------------------------------------------
| SMTP Host Address
|--------------------------------------------------------------------------
|
| Here you may provide the host address of the SMTP server used by your
| applications. A default option is provided that is compatible with
| the Mailgun mail service which will provide reliable deliveries.
|
*/
'host' => 'smtp.mailgun.org',
'host' => env('EMAIL_SMTP', 'smtp.mailgun.org'),
/*
|--------------------------------------------------------------------------
| SMTP Host Port
|--------------------------------------------------------------------------
|
| 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
| stay compatible with the Mailgun e-mail application by default.
|
*/
/*
|--------------------------------------------------------------------------
| SMTP Host Port
|--------------------------------------------------------------------------
|
| 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
| stay compatible with the Mailgun e-mail application by default.
|
*/
'port' => 587,
'port' => 587,
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| 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
| used globally for all e-mails that are sent by your application.
|
*/
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| 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
| 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
|--------------------------------------------------------------------------
|
| Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible default using the
| transport layer security protocol should provide great security.
|
*/
/*
|--------------------------------------------------------------------------
| E-Mail Encryption Protocol
|--------------------------------------------------------------------------
|
| Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible default using the
| transport layer security protocol should provide great security.
|
*/
'encryption' => 'tls',
'encryption' => 'tls',
/*
|--------------------------------------------------------------------------
| SMTP Server Username
|--------------------------------------------------------------------------
|
| If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one.
|
*/
/*
|--------------------------------------------------------------------------
| SMTP Server Username
|--------------------------------------------------------------------------
|
| If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one.
|
*/
'username' => null,
'username' => env('EMAIL_USERNAME', null),
/*
|--------------------------------------------------------------------------
| SMTP Server Password
|--------------------------------------------------------------------------
|
| 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
| connection so that the application will be able to send messages.
|
*/
/*
|--------------------------------------------------------------------------
| SMTP Server Password
|--------------------------------------------------------------------------
|
| 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
| connection so that the application will be able to send messages.
|
*/
'password' => null,
'password' => env('EMAIL_PASSWORD', null),
/*
|--------------------------------------------------------------------------
| Sendmail System Path
|--------------------------------------------------------------------------
|
| 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
| been provided here, which will work well on most of your systems.
|
*/
/*
|--------------------------------------------------------------------------
| Sendmail System Path
|--------------------------------------------------------------------------
|
| 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
| been provided here, which will work well on most of your systems.
|
*/
'sendmail' => '/usr/sbin/sendmail -bs',
'sendmail' => '/usr/sbin/sendmail -bs',
/*
|--------------------------------------------------------------------------
| Mail "Pretend"
|--------------------------------------------------------------------------
|
| 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
| you may inspect the message. This is great for local development.
|
*/
/*
|--------------------------------------------------------------------------
| Mail "Pretend"
|--------------------------------------------------------------------------
|
| 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
| 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>
</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">
</div>
<div class="form-group">
<input type="password" class="form-control" id="inputPassword" name="password" placeholder="Password">
</div>
<div class="form-group">
<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="row">
<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

@ -3,8 +3,10 @@
@section('content')
<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="login-panel panel panel-default">
<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>
</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="row">
<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,37 +18,29 @@
</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">
Reset Password
</button>
</div>
<button type="submit" class="btn btn-success btn-lg btn-block">
Reset Password
</button>
</div>
</form>
</div>