1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Temp routes"

This commit is contained in:
David Bomba 2020-11-27 20:14:01 +11:00
parent 1ab56a53a2
commit 5a3c93bb3c
3 changed files with 43 additions and 3 deletions

View 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);
}
}

View File

@ -87,11 +87,15 @@ class Phantom
public function convertHtmlToPdf($html) public function convertHtmlToPdf($html)
{ {
$hash = Str::random(32);
Cache::put($hash, $html, 300);
$url = route('tmp_pdf', ['hash' => $hash]);
$key = config('ninja.phantomjs_key'); $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); $pdf = CurlUtils::get($phantom_url);
info($pdf);
$response = Response::make($pdf, 200); $response = Response::make($pdf, 200);
$response->header('Content-Type', 'application/pdf'); $response->header('Content-Type', 'application/pdf');

View File

@ -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::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::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']); Route::get('client/key_login/{contact_key}', 'ClientPortal\ContactHashLoginController@login')->name('client.contact_login')->middleware(['contact_key_login']);
//todo implement domain DB //todo implement domain DB