Remove Spatie Ray - poor error handling

This commit is contained in:
David Bomba 2021-01-30 12:13:32 +11:00
parent 3c72a15707
commit 65ee07b8ec
4 changed files with 209 additions and 727 deletions

View File

@ -35,10 +35,10 @@ function nlog($output, $context = []): void
} }
if (!function_exists('ray')) { // if (!function_exists('ray')) {
function ray($payload) // function ray($payload)
{ // {
return true; // return true;
} // }
} // }

View File

@ -33,6 +33,8 @@ class InvitationController extends Controller
public function router(string $entity, string $invitation_key) public function router(string $entity, string $invitation_key)
{ {
Auth::logout();
return $this->genericRouter($entity, $invitation_key); return $this->genericRouter($entity, $invitation_key);
} }
@ -43,6 +45,7 @@ class InvitationController extends Controller
private function genericRouter(string $entity, string $invitation_key) private function genericRouter(string $entity, string $invitation_key)
{ {
$key = $entity.'_id'; $key = $entity.'_id';
$entity_obj = 'App\Models\\'.ucfirst(Str::camel($entity)).'Invitation'; $entity_obj = 'App\Models\\'.ucfirst(Str::camel($entity)).'Invitation';
@ -51,17 +54,24 @@ class InvitationController extends Controller
->with('contact.client') ->with('contact.client')
->firstOrFail(); ->firstOrFail();
nlog($invitation->contact->client->id);
nlog($invitation->invoice->client_id);
/* Return early if we have the correct client_hash embedded */ /* Return early if we have the correct client_hash embedded */
if (request()->has('client_hash') && request()->input('client_hash') == $invitation->contact->client->client_hash) { if (request()->has('client_hash') && request()->input('client_hash') == $invitation->contact->client->client_hash) {
auth()->guard('contact')->login($invitation->contact, true); auth()->guard('contact')->login($invitation->contact, true);
} elseif ((bool) $invitation->contact->client->getSetting('enable_client_portal_password') !== false) { } elseif ((bool) $invitation->contact->client->getSetting('enable_client_portal_password') !== false) {
//If no contact password is set - this will cause a 401 error - instead redirect to the client.login route
$this->middleware('auth:contact'); $this->middleware('auth:contact');
return redirect()->route('client.login');
} else { } else {
auth()->guard('contact')->login($invitation->contact, true); auth()->guard('contact')->login($invitation->contact, true);
} }
if (auth()->guard('contact') && ! request()->has('silent') && ! $invitation->viewed_date) { if (auth()->guard('contact') && ! request()->has('silent') && ! $invitation->viewed_date) {
$invitation->markViewed(); $invitation->markViewed();

View File

@ -79,7 +79,6 @@
"mockery/mockery": "^1.3.1", "mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^5.0", "nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.0", "phpunit/phpunit": "^9.0",
"spatie/laravel-ray": "^1.3",
"vimeo/psalm": "^4.0", "vimeo/psalm": "^4.0",
"wildbit/postmark-php": "^4.0" "wildbit/postmark-php": "^4.0"
}, },

909
composer.lock generated

File diff suppressed because it is too large Load Diff