Upload-Share: Route registriert, Fehlversuche-Limit, PW kopieren, bessere Fehlerbehandlung

This commit is contained in:
2026-06-05 23:25:45 +02:00
parent 7e19a6580e
commit e7ebf2d831
5 changed files with 187 additions and 189 deletions

View File

@@ -521,46 +521,13 @@ if (!db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='cal
`);
}
// ── Upload-Freigaben (externer Upload-Link) ───────────────────────────────────
if (!db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='upload_shares'").get()) {
db.exec(`
CREATE TABLE upload_shares (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
token TEXT NOT NULL UNIQUE,
password_hash TEXT NOT NULL,
expires_at DATETIME NOT NULL,
max_size_mb INTEGER NOT NULL DEFAULT 10,
folder_id INTEGER REFERENCES folders(id) ON DELETE SET NULL,
is_active INTEGER NOT NULL DEFAULT 1,
created_at DATETIME DEFAULT NULL
)
`);
}
if (!db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='upload_share_logs'").get()) {
db.exec(`
CREATE TABLE upload_share_logs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
share_id INTEGER NOT NULL REFERENCES upload_shares(id) ON DELETE CASCADE,
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
originalname TEXT NOT NULL,
size INTEGER NOT NULL DEFAULT 0,
ip_address TEXT NOT NULL DEFAULT '',
uploaded_at DATETIME DEFAULT NULL
)
`);
}
// allow_upload_share Recht pro User
// upload_shares Fehlversuche-Tracking
{
const userCols = db.pragma('table_info(users)').map(c => c.name);
if (!userCols.includes('allow_upload_share'))
db.exec('ALTER TABLE users ADD COLUMN allow_upload_share INTEGER DEFAULT 0');
}
// Upload-Ordner Flag auf Folders-Tabelle
{
const folderCols = db.pragma('table_info(folders)').map(c => c.name);
if (!folderCols.includes('is_upload_folder'))
db.exec('ALTER TABLE folders ADD COLUMN is_upload_folder INTEGER DEFAULT 0');
const usCols = db.pragma('table_info(upload_shares)').map(c => c.name);
if (!usCols.includes('failed_attempts'))
db.exec('ALTER TABLE upload_shares ADD COLUMN failed_attempts INTEGER DEFAULT 0');
if (!usCols.includes('deactivated_reason'))
db.exec("ALTER TABLE upload_shares ADD COLUMN deactivated_reason TEXT DEFAULT NULL");
}
module.exports = db;