Upload via GUI (338 Dateien)
This commit is contained in:
@@ -105,9 +105,9 @@ function api_issue_token(PDO $pdo, int $staffId, ?string $deviceName): array
|
||||
}
|
||||
|
||||
$pdo->prepare(
|
||||
'INSERT INTO mobile_api_tokens (staff_id, token_hash, device_name, expires_at, created_at)
|
||||
VALUES (?,?,?,?,?)'
|
||||
)->execute([$staffId, hash('sha256', $token), $deviceName, $expiresAt, db_now()]);
|
||||
'INSERT INTO mobile_api_tokens (staff_id, token_hash, device_name, expires_at, created_at, last_used_at)
|
||||
VALUES (?,?,?,?,?,?)'
|
||||
)->execute([$staffId, hash('sha256', $token), $deviceName, $expiresAt, db_now(), db_now()]);
|
||||
|
||||
return ['token' => $token, 'expires_at' => $expiresAt];
|
||||
}
|
||||
@@ -133,11 +133,10 @@ function api_require_staff(): array
|
||||
api_error(401, 'TOKEN_EXPIRED', 'Die Anmeldung ist abgelaufen. Bitte melden Sie sich erneut an.');
|
||||
}
|
||||
|
||||
$lastUsed = $staff['mobile_token_last_used_at'] ?? null;
|
||||
if (!$lastUsed || strtotime($lastUsed) < time() - 300) {
|
||||
$pdo->prepare('UPDATE mobile_api_tokens SET last_used_at = ? WHERE id = ?')
|
||||
->execute([db_now(), $staff['mobile_token_id']]);
|
||||
}
|
||||
// Jede authentifizierte Anfrage ist ein App-Heartbeat. So bleibt der Status
|
||||
// auch bei regelmaessiger Nutzung mit weniger als 5 Minuten Abstand aktuell.
|
||||
$pdo->prepare('UPDATE mobile_api_tokens SET last_used_at = ? WHERE id = ?')
|
||||
->execute([db_now(), $staff['mobile_token_id']]);
|
||||
|
||||
// Aktionen in der App (Schreib-Aufrufe) zählen als Aktivität; reines Abfragen im Hintergrund und die Push-Anmeldung nicht
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'GET' && !in_array(basename((string) ($_SERVER['SCRIPT_NAME'] ?? '')), ['push_device.php', 'crash_report.php', 'logout.php'], true)) {
|
||||
|
||||
Reference in New Issue
Block a user