mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Temp routes"
This commit is contained in:
parent
1ab56a53a2
commit
5a3c93bb3c
34
app/Http/Controllers/ClientPortal/TempRouteController.php
Normal file
34
app/Http/Controllers/ClientPortal/TempRouteController.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers\ClientPortal;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class TempRouteController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Logs a user into the client portal using their contact_key
|
||||
* @param string $contact_key The contact key
|
||||
* @return Auth|Redirect
|
||||
*/
|
||||
public function index(string $hash)
|
||||
{
|
||||
|
||||
$html = Cache::get($hash);
|
||||
|
||||
return view('pdf.html', $html);
|
||||
|
||||
}
|
||||
}
|
@ -87,11 +87,15 @@ class Phantom
|
||||
|
||||
public function convertHtmlToPdf($html)
|
||||
{
|
||||
|
||||
$hash = Str::random(32);
|
||||
Cache::put($hash, $html, 300);
|
||||
|
||||
$url = route('tmp_pdf', ['hash' => $hash]);
|
||||
|
||||
$key = config('ninja.phantomjs_key');
|
||||
$phantom_url = "https://phantomjscloud.com/api/browser/v2/{$key}/?request=%7Bcontent:%22{$html}%22,renderType:%22pdf%22%7D";
|
||||
$phantom_url = "https://phantomjscloud.com/api/browser/v2/{$key}/?request=%url:%22{$url}%22,renderType:%22pdf%22%7D";
|
||||
$pdf = CurlUtils::get($phantom_url);
|
||||
info($pdf);
|
||||
|
||||
$response = Response::make($pdf, 200);
|
||||
$response->header('Content-Type', 'application/pdf');
|
||||
|
||||
|
@ -19,6 +19,8 @@ Route::get('view/{entity_type}/{invitation_key}', 'ClientPortal\EntityViewContro
|
||||
Route::get('view/{entity_type}/{invitation_key}/password', 'ClientPortal\EntityViewController@password')->name('client.entity_view.password');
|
||||
Route::post('view/{entity_type}/{invitation_key}/password', 'ClientPortal\EntityViewController@handlePassword');
|
||||
|
||||
Route::get('tmp_pdf/{hash}', 'ClientPortal\TempRouteController@index')->name('tmp_pdf');
|
||||
|
||||
Route::get('client/key_login/{contact_key}', 'ClientPortal\ContactHashLoginController@login')->name('client.contact_login')->middleware(['contact_key_login']);
|
||||
|
||||
//todo implement domain DB
|
||||
|
Loading…
x
Reference in New Issue
Block a user