- send User-Agent "OrderApp/1.4.0 (linux) QloApps-CasposBridge/1.0" and version 1.4.0: CASPOS classifies non-OrderApp clients as "Orderman", which cannot be activated in the Order-App device manager - fixed prices for open-price articles: ARTICLE@12.50 / @12,50 (cents) - live test (docker/test-casposbridge-live.php) booked one night on table 101: 1 x 301 @ 145.00 + 2 x 101 @ 12.50, bookedAmount 17000, lines committed -> enteredPrice is in cents - README: device activation, waiter key, per-area table number ranges ("Ungültige Tischnummer"), results - docker/reset-admin-password.php: set a back-office password from the CLI (asked interactively, not echoed) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
1.7 KiB
PHP
51 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* Set a new password for a back-office employee (command line only).
|
|
* docker compose -f docker-compose.yml -f docker-compose.server.yml exec -u www-data app php docker/reset-admin-password.php admin@hotel.test
|
|
* The password is asked interactively (not echoed) so it does not end up in the shell history.
|
|
* Use "exec" without -T so the prompt works.
|
|
*/
|
|
if (PHP_SAPI !== 'cli') {
|
|
exit;
|
|
}
|
|
define('_PS_ADMIN_DIR_', __DIR__);
|
|
require __DIR__.'/../config/config.inc.php';
|
|
|
|
$email = isset($argv[1]) ? trim($argv[1]) : '';
|
|
if (!Validate::isEmail($email)) {
|
|
fwrite(STDERR, "Usage: php docker/reset-admin-password.php <admin-email>\n");
|
|
foreach (Db::getInstance()->executeS('SELECT email, active FROM `'._DB_PREFIX_.'employee`') as $e) {
|
|
fwrite(STDERR, ' vorhandener Zugang: '.$e['email'].($e['active'] ? '' : ' (inaktiv)')."\n");
|
|
}
|
|
exit(1);
|
|
}
|
|
$employee = new Employee();
|
|
if (!$employee->getByEmail($email)) {
|
|
fwrite(STDERR, "Kein Zugang mit der E-Mail $email.\n");
|
|
exit(1);
|
|
}
|
|
|
|
function ask($prompt)
|
|
{
|
|
fwrite(STDOUT, $prompt);
|
|
@shell_exec('stty -echo 2>/dev/null');
|
|
$v = rtrim((string)fgets(STDIN), "\r\n");
|
|
@shell_exec('stty echo 2>/dev/null');
|
|
fwrite(STDOUT, "\n");
|
|
return $v;
|
|
}
|
|
$p1 = ask('Neues Passwort (mind. 8 Zeichen): ');
|
|
$p2 = ask('Wiederholen: ');
|
|
if ($p1 !== $p2 || Tools::strlen($p1) < 8) {
|
|
fwrite(STDERR, "Passwörter verschieden oder kürzer als 8 Zeichen.\n");
|
|
exit(1);
|
|
}
|
|
$employee->passwd = (new PasswordHashing())->passwordHash($p1);
|
|
$employee->last_passwd_gen = date('Y-m-d H:i:s');
|
|
$employee->active = 1;
|
|
if (!$employee->update()) {
|
|
fwrite(STDERR, "Speichern fehlgeschlagen.\n");
|
|
exit(1);
|
|
}
|
|
echo "Passwort für $email gesetzt. Anmeldung: /admin-dev/\n";
|