From 34bf7a23d13c326f316a4b4c82785ca4bbdd7b40 Mon Sep 17 00:00:00 2001 From: thiritin Date: Mon, 16 Sep 2024 14:20:57 +0200 Subject: [PATCH] fix printer auth --- .../js/Components/POS/QZPrintService.vue | 10 +++--- routes/pos-auth.php | 33 ++++++++++++++----- routes/pos.php | 8 +---- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/resources/js/Components/POS/QZPrintService.vue b/resources/js/Components/POS/QZPrintService.vue index 9989406..9c093fd 100644 --- a/resources/js/Components/POS/QZPrintService.vue +++ b/resources/js/Components/POS/QZPrintService.vue @@ -18,7 +18,7 @@ onMounted(function() { } }); qz.security.setCertificatePromise(function (resolve, reject) { - fetch(route('pos.qz.cert'), {cache: 'no-store', headers: {'Content-Type': 'text/plain'}}) + fetch(route('pos.auth.qz.cert'), {cache: 'no-store', headers: {'Content-Type': 'text/plain'}}) .then(function (data) { data.ok ? resolve(data.text()) : reject(data.text()); }); @@ -26,7 +26,7 @@ onMounted(function() { qz.security.setSignatureAlgorithm("SHA512"); // Since 2.1 qz.security.setSignaturePromise(function (toSign) { return function (resolve, reject) { - fetch("/pos/qz/sign?request=" + toSign, {cache: 'no-store', headers: {'Content-Type': 'text/plain'}}) + fetch("/pos/auth/qz/sign?request=" + toSign, {cache: 'no-store', headers: {'Content-Type': 'text/plain'}}) .then(function (data) { data.ok ? resolve(data.text()) : reject(data.text()); }); @@ -57,11 +57,11 @@ function startQZPrint() { function pollPrintJobs() { setInterval(() => { - http.get(route('pos.printers.jobs'),{},{ + http.get(route('pos.auth.printers.jobs'),{},{ onSuccess(printJobs) { printJobs.data.forEach((job) => { console.log("job", job); - http.post(route('pos.printers.jobs.printed', {job: job.id}), {}, { + http.post(route('pos.auth.printers.jobs.printed', {job: job.id}), {}, { onSuccess() { var printerOptions = (job.type === 'badge') ? { colorType: 'color', @@ -98,7 +98,7 @@ function pollPrintJobs() { function findPrinters() { qz.printers.details().then((printers) => { - http.post(route('pos.printers.store'), {printers: printers}); + http.post(route('pos.auth.printers.store'), {printers: printers}); }).catch((err) => { console.error(err); }); diff --git a/routes/pos-auth.php b/routes/pos-auth.php index 060c06b..a235298 100644 --- a/routes/pos-auth.php +++ b/routes/pos-auth.php @@ -1,5 +1,7 @@ group(function() { + Route::post('/logout', [\App\Http\Controllers\POS\Auth\MachineUserAuthController::class, 'logout']) + ->name('user.logout'); + Route::get('/login', [\App\Http\Controllers\POS\Auth\MachineUserAuthController::class, 'selectUser']) + ->name('user.select'); + Route::get('/login/{user}', [\App\Http\Controllers\POS\Auth\MachineUserAuthController::class, 'showLogin']) + ->name('user.login.show'); + Route::post('/login/{user}', [\App\Http\Controllers\POS\Auth\MachineUserAuthController::class, 'submitLogin']) + ->name('user.login.submit'); + + + /** + * CONTAINS ALL ROUTES FOR POS SYSTEM - AUTHENTICATED + */ +// QZ Tray + Route::get('/qz/sign', [QzCertController::class,'sign'])->name('qz.sign'); + Route::get('/qz/cert', [QzCertController::class,'cert'])->name('qz.cert'); +// Cashier / Checkout stuff + Route::post('/printers/store',[PrinterController::class,'store'])->name('printers.store'); + Route::get('/printers/jobs',[PrinterController::class, 'jobIndex'])->name('printers.jobs'); + Route::post('/printers/jobs/{job}/printed',[PrinterController::class, 'jobPrinted'])->name('printers.jobs.printed'); + +}); -Route::post('/logout', [\App\Http\Controllers\POS\Auth\MachineUserAuthController::class, 'logout']) - ->name('user.logout'); -Route::get('/login', [\App\Http\Controllers\POS\Auth\MachineUserAuthController::class, 'selectUser']) - ->name('user.select'); -Route::get('/login/{user}', [\App\Http\Controllers\POS\Auth\MachineUserAuthController::class, 'showLogin']) - ->name('user.login.show'); -Route::post('/login/{user}', [\App\Http\Controllers\POS\Auth\MachineUserAuthController::class, 'submitLogin']) - ->name('user.login.submit'); diff --git a/routes/pos.php b/routes/pos.php index bd806fa..bb55cc9 100644 --- a/routes/pos.php +++ b/routes/pos.php @@ -24,13 +24,7 @@ }); // Print Badge Route::post('/badges/{badge}/print', \App\Http\Controllers\POS\Printing\PrintBadgeController::class)->name('badges.print'); -// QZ Tray -Route::get('/qz/sign', [QzCertController::class,'sign'])->name('qz.sign'); -Route::get('/qz/cert', [QzCertController::class,'cert'])->name('qz.cert'); -// Cashier / Checkout stuff -Route::post('/printers/store',[\App\Http\Controllers\POS\Printing\PrinterController::class,'store'])->name('printers.store'); -Route::get('/printers/jobs',[\App\Http\Controllers\POS\Printing\PrinterController::class, 'jobIndex'])->name('printers.jobs'); -Route::post('/printers/jobs/{job}/printed',[\App\Http\Controllers\POS\Printing\PrinterController::class, 'jobPrinted'])->name('printers.jobs.printed'); +// Print QZ Cert Route::post('/badges/{badge}/handout', [\App\Http\Controllers\POS\BadgeController::class,'handout'])->name('badges.handout'); Route::post('/badges/{badge}/handout/undo', [\App\Http\Controllers\POS\BadgeController::class, 'handoutUndo'])->name('badges.handout.undo'); Route::post('/badges/handout/bulk', [\App\Http\Controllers\POS\BadgeController::class, 'handoutBulk'])->name('badges.handout.bulk');