Skip to content

Commit

Permalink
fix printer auth
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiritin committed Sep 16, 2024
1 parent dbd3097 commit 34bf7a2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
10 changes: 5 additions & 5 deletions resources/js/Components/POS/QZPrintService.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ 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());
});
});
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());
});
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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);
});
Expand Down
33 changes: 25 additions & 8 deletions routes/pos-auth.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use App\Http\Controllers\POS\Printing\PrinterController;
use App\Http\Controllers\POS\Printing\QzCertController;
use Illuminate\Support\Facades\Route;

// Signed route machine login
Expand All @@ -10,12 +12,27 @@
/**
* AUTHENTICATION ROUTES
*/
Route::middleware('auth:machine')->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');
8 changes: 1 addition & 7 deletions routes/pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 34bf7a2

Please sign in to comment.