2019-09-23 07:59:01 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\ClientPortal;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Models\InvoiceInvitation;
|
|
|
|
use App\Utils\Traits\MakesDates;
|
|
|
|
use App\Utils\Traits\MakesHash;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class InvitationController
|
|
|
|
* @package App\Http\Controllers\ClientPortal\InvitationController
|
|
|
|
*/
|
|
|
|
|
|
|
|
class InvitationController extends Controller
|
|
|
|
{
|
|
|
|
|
|
|
|
use MakesHash;
|
|
|
|
use MakesDates;
|
|
|
|
|
2019-11-16 04:12:29 +01:00
|
|
|
public function router(string $entity, string $invitation_key)
|
2019-09-23 07:59:01 +02:00
|
|
|
{
|
2019-11-16 04:12:29 +01:00
|
|
|
$key = $entity.'_id';
|
2019-11-21 09:38:57 +01:00
|
|
|
$entity_obj = 'App\Models\\'.ucfirst($entity).'Invitation';
|
2019-09-23 07:59:01 +02:00
|
|
|
|
2019-11-16 04:12:29 +01:00
|
|
|
$invitation = $entity_obj::whereRaw("BINARY `key`= ?", [$invitation_key])->first();
|
2019-09-23 07:59:01 +02:00
|
|
|
|
|
|
|
if($invitation){
|
2019-11-04 01:22:59 +01:00
|
|
|
|
|
|
|
if((bool)$invitation->contact->client->getSetting('enable_client_portal_password') !== false)
|
|
|
|
$this->middleware('auth:contact');
|
2019-11-21 09:38:57 +01:00
|
|
|
else
|
|
|
|
auth()->guard('contact')->login($invitation->contact, false);
|
|
|
|
|
2019-11-04 01:22:59 +01:00
|
|
|
$invitation->markViewed();
|
|
|
|
|
2019-11-16 04:12:29 +01:00
|
|
|
return redirect()->route('client.'.$entity.'.show', [$entity => $this->encodePrimaryKey($invitation->{$key})]);
|
2019-11-04 01:22:59 +01:00
|
|
|
|
2019-09-23 07:59:01 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
abort(404);
|
|
|
|
|
|
|
|
}
|
2019-11-06 23:57:09 +01:00
|
|
|
|
2019-11-16 04:12:29 +01:00
|
|
|
public function routerForIframe(string $entity, string $client_hash, string $invitation_key)
|
|
|
|
{
|
2019-11-06 23:57:09 +01:00
|
|
|
|
2019-11-16 04:12:29 +01:00
|
|
|
}
|
2019-11-06 23:57:09 +01:00
|
|
|
|
2019-09-23 07:59:01 +02:00
|
|
|
}
|