Skip to content

Firefly III: a personal finances manager

Merge branch 'apifix' into develop

James Coled2a8819dd44f
diff --cc app/Http/Middleware/HttpBinder.php
index fca7d481cf,48e04243c9..d9566e3ac0
--- a/app/Http/Middleware/HttpBinder.php
+++ b/app/Http/Middleware/HttpBinder.php
@@@ -24,15 -24,20 +24,21 @@@ namespace FireflyIII\Http\Middleware
use Closure;
use FireflyIII\Support\Domain;
- use Illuminate\Auth\SessionGuard;
+ use Illuminate\Contracts\Auth\Factory as Auth;
use Illuminate\Http\Request;
+use Illuminate\Routing\Route;
/**
- * Class Binder.
+ * Class HttpBinder
*/
-class Binder
+class HttpBinder
{
+ /**
+ * The authentication factory instance.
+ *
+ * @var \Illuminate\Contracts\Auth\Factory
+ */
+ protected $auth;
/**
* @var array
*/
@@@ -49,23 -57,19 +58,26 @@@
/**
* Handle an incoming request.
*
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
+ * @param \Illuminate\Http\Request $request
+ * @param \Closure $next
+ * @param string[] ...$guards
*
* @return mixed
+ *
+ * @throws \Illuminate\Auth\AuthenticationException
*/
- public function handle(Request $request, Closure $next)
+ public function handle($request, Closure $next, ...$guards)
{
+ $middleware = $request->route()->middleware();
+ $guard = 'web';
+ if(in_array('auth:api', $middleware)) {
+ $guard = 'api';
+ }
+ $guard = auth()->guard($guard);
+
foreach ($request->route()->parameters() as $key => $value) {
if (isset($this->binders[$key])) {
- $boundObject = $this->performBinding($key, $value, $request->route());
+ $boundObject = $this->performBinding($guard, $key, $value, $request->route());
$request->route()->setParameter($key, $boundObject);
}
}
diff --cc app/Transformers/BillTransformer.php
index 86b9244d21,0394ad0037..80859a7ee2
--- a/app/Transformers/BillTransformer.php
+++ b/app/Transformers/BillTransformer.php
@@@ -72,7 -72,8 +72,7 @@@ class BillTransformer extends Transform
{
$attachments = $bill->attachments()->get();
-- return $this->collection($attachments, new AttachmentTransformer,'attachment');
-
++ return $this->collection($attachments, new AttachmentTransformer, 'attachment');
}
/**
@@@ -84,7 -85,8 +84,7 @@@
{
$notes = $bill->notes()->get();
-- return $this->collection($notes, new NoteTransformer,'note');
-
++ return $this->collection($notes, new NoteTransformer, 'note');
}
/**