1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 08:51:34 +02:00
invoiceninja/app/Http/Controllers/ClientPortal/InvitationController.php
David Bomba 69efd4d574
Enhancements to API (#3088)
* working on email throttling

* Fixes for invitaiton links

* pass custom fields as object

* Add user agent to company token

* Update company token transformer

* Remove prefix setting from CompanySettings

* Implement user agent on company token & provide better error handling for undefined relationships includes

* Fix bulk actions

* Working on updating/creating a company user

* Fixes for tests
2019-11-21 19:38:57 +11:00

62 lines
1.6 KiB
PHP

<?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;
public function router(string $entity, string $invitation_key)
{
$key = $entity.'_id';
$entity_obj = 'App\Models\\'.ucfirst($entity).'Invitation';
$invitation = $entity_obj::whereRaw("BINARY `key`= ?", [$invitation_key])->first();
if($invitation){
if((bool)$invitation->contact->client->getSetting('enable_client_portal_password') !== false)
$this->middleware('auth:contact');
else
auth()->guard('contact')->login($invitation->contact, false);
$invitation->markViewed();
return redirect()->route('client.'.$entity.'.show', [$entity => $this->encodePrimaryKey($invitation->{$key})]);
}
else
abort(404);
}
public function routerForIframe(string $entity, string $client_hash, string $invitation_key)
{
}
}