Skip to content

Commit c657288

Browse files
committed
29 Jan 2024
Some code clean up: 1) NFC & QR login lib - Check valid user before creating hash. 2) Combined user login and item batch to use the same QR generation page. 3) Removed user login QR code page.
1 parent b10dc23 commit c657288

14 files changed

+56
-46
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Storage Boxx is an open-source PHP Inventory Management System. With a built-in
55
## :white_check_mark: "OUT OF THE BOX" FEATURES
66
1) Generate item QR code, built-in QR code scanner.
77
2) Create item NFC tags, built-in NFC scanner.
8-
3) Passwordless login - NFC and Web Authentication (Biometric, PIN, Face Recognition)
8+
3) Passwordless login - QR, NFC, Web Authentication (Biometric, PIN, Face Recognition).
99
4) Stock level monitoring, push notifications on low stock.
1010
5) Batch and expiration tracking.
1111
6) Installable progressive web app.
@@ -32,7 +32,7 @@ Storage Boxx is an open-source PHP Inventory Management System. With a built-in
3232
<br><br>
3333

3434
## :floppy_disk: INSTALLATION
35-
1) Copy & unzip into your `http` folder.
35+
1) Manually download or git clone into your `http` folder.
3636
2) Access `http://your-site.com/` in your browser and walk through the installer.
3737
3) If you want, add the [optional AI Assistant](https://github.com/code-boxx/Storage-Boxx-AI) after the installation.
3838
<br><br>

assets/PAGE-batch.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ var batch = {
8181
})),
8282

8383
// (H) GENERATE QR CODE
84-
qr : (sku, name) => window.open(cbhost.base + "qrcode/?sku="+sku+"&name="+name),
84+
qr : (sku, name) => {
85+
document.getElementById("qrsku").value = sku;
86+
document.getElementById("qrbatch").value = name;
87+
document.getElementById("qrform").submit();
88+
},
8589

8690
// (I) SHOW WRITE NFC SCREEN
8791
nfcSKU : null, // current sku to write
@@ -151,6 +155,7 @@ var batch = {
151155
]
152156
})
153157
};
158+
154159
window.addEventListener("load", () => {
155160
batch.list();
156161
autocomplete.attach({

assets/storage-boxx-1.png

-801 Bytes
Loading

assets/storage-boxx-2.png

-2.48 KB
Loading

assets/storage-boxx-3.png

9.64 KB
Loading

assets/storage-boxx-4.png

-26.8 KB
Loading

assets/storage-boxx-5.png

-13.6 KB
Loading

assets/storage-boxx-6.png

19.6 KB
Loading

lib/LIB-NFCIN.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ function __construct ($core) {
1010
// (B) CREATE NEW NFC LOGIN TOKEN
1111
// $id : user id
1212
function add ($id) {
13-
// (B1) UPDATE TOKEN
13+
// (B1) CHECK VALID USER
14+
if (!is_array($this->Users->get($id))) {
15+
$this->error = "Invalid user";
16+
return false;
17+
}
18+
19+
// (B2) UPDATE TOKEN
1420
$token = $this->Core->random($this->nlen);
1521
$this->Users->hashAdd($id, "NFC", password_hash($token, PASSWORD_DEFAULT));
1622

17-
// (B2) RETURN ENCODED TOKEN
23+
// (B3) RETURN ENCODED TOKEN
1824
require PATH_LIB . "JWT/autoload.php";
1925
return Firebase\JWT\JWT::encode([$id, $token], JWT_SECRET, JWT_ALGO);
2026
}

lib/LIB-QRIN.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ function __construct ($core) {
1010
// (B) CREATE NEW NFC LOGIN TOKEN
1111
// $id : user id
1212
function add ($id) {
13-
// (B1) UPDATE TOKEN
13+
// (B1) CHECK VALID USER
14+
if (!is_array($this->Users->get($id))) {
15+
$this->error = "Invalid user";
16+
return false;
17+
}
18+
19+
// (B2) UPDATE TOKEN
1420
$token = $this->Core->random($this->nlen);
1521
$this->Users->hashAdd($id, "QR", password_hash($token, PASSWORD_DEFAULT));
1622

17-
// (B2) RETURN ENCODED TOKEN
23+
// (B3) RETURN ENCODED TOKEN
1824
require PATH_LIB . "JWT/autoload.php";
1925
return Firebase\JWT\JWT::encode([$id, $token], JWT_SECRET, JWT_ALGO);
2026
}

0 commit comments

Comments
 (0)