Update to latest version
This commit is contained in:
1 parent
7125e29993
commit
c74ef9cf9c
15 files changed
+190
-69
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"workspace_id": "6c5e-09e0-3a93-f4a1",
|
||||||
|
"workspace_id_at": "2026-05-14T10:44:35Z",
|
||||||
|
"project_name": "DuneDashboard"
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
# SpecStory CLI Configuration
|
||||||
|
#
|
||||||
|
# This is the project-level config file for SpecStory CLI.
|
||||||
|
# All settings here apply to this project unless overridden by CLI flags.
|
||||||
|
#
|
||||||
|
# Uncomment (remove the #) the line and edit any setting below to change the default behavior.
|
||||||
|
# For more information, see: https://docs.specstory.com/integrations/terminal-coding-agents/usage
|
||||||
|
|
||||||
|
[local_sync]
|
||||||
|
# Write markdown files locally. (default: true)
|
||||||
|
# enabled = false # equivalent to --only-cloud-sync
|
||||||
|
|
||||||
|
# Custom output directory for markdown files.
|
||||||
|
# Default: ./.specstory/history (relative to the project directory)
|
||||||
|
# output_dir = "~/.specstory/history" # equivalent to --output-dir "~/.specstory/history"
|
||||||
|
|
||||||
|
# Use local timezone for file name and content timestamps (default: false, UTC)
|
||||||
|
# local_time_zone = true # equivalent to --local-time-zone
|
||||||
|
|
||||||
|
[cloud_sync]
|
||||||
|
# Sync session data to SpecStory Cloud. (default: true, when logged in to SpecStory Cloud)
|
||||||
|
# enabled = false # equivalent to --no-cloud-sync
|
||||||
|
|
||||||
|
[logging]
|
||||||
|
# Write logs to .specstory/debug/debug.log (default: false)
|
||||||
|
# log = true # equivalent to --log
|
||||||
|
|
||||||
|
# Debug-level output, requires console or log (default: false)
|
||||||
|
# debug = true # equivalent to --debug
|
||||||
|
|
||||||
|
# Custom output directory for debug data.
|
||||||
|
# Default: ./.specstory/debug (relative to the project directory)
|
||||||
|
# debug_dir = "~/.specstory/debug" # equivalent to --debug-dir "~/.specstory/debug"
|
||||||
|
|
||||||
|
# Error/warn/info output to stdout (default: false)
|
||||||
|
# console = true # equivalent to --console
|
||||||
|
|
||||||
|
# Suppress all non-error output (default: false)
|
||||||
|
# silent = true # equivalent to --silent
|
||||||
|
|
||||||
|
[version_check]
|
||||||
|
# Check for new versions of the CLI on startup.
|
||||||
|
# Default: true
|
||||||
|
# enabled = false # equivalent to --no-version-check
|
||||||
|
|
||||||
|
[analytics]
|
||||||
|
# Send anonymous product usage analytics to help improve SpecStory.
|
||||||
|
# Default: true
|
||||||
|
# enabled = false # equivalent to --no-usage-analytics
|
||||||
|
|
||||||
|
[telemetry]
|
||||||
|
# OTLP gRPC collector endpoint (e.g., "localhost:4317" or "http://localhost:4317")
|
||||||
|
# endpoint = "localhost:4317"
|
||||||
|
|
||||||
|
# Override the default service name (default: "specstory-cli")
|
||||||
|
# service_name = "my-service-name"
|
||||||
|
|
||||||
|
# Include user prompt text in telemetry spans (default: true)
|
||||||
|
# prompts = false
|
||||||
|
|
||||||
|
[providers]
|
||||||
|
# Agent execution commands by provider (used by specstory run)
|
||||||
|
# Pass custom flags (e.g. claude_cmd = "claude --allow-dangerously-skip-permissions")
|
||||||
|
# Use of these is equivalent to -c "custom command"
|
||||||
|
|
||||||
|
# Claude Code command
|
||||||
|
# claude_cmd = "claude"
|
||||||
|
|
||||||
|
# Codex CLI command
|
||||||
|
# codex_cmd = "codex"
|
||||||
|
|
||||||
|
# Cursor CLI command
|
||||||
|
# cursor_cmd = "cursor-agent"
|
||||||
|
|
||||||
|
# Droid CLI command
|
||||||
|
# droid_cmd = "droid"
|
||||||
|
|
||||||
|
# Gemini CLI command
|
||||||
|
# gemini_cmd = "gemini"
|
||||||
+8
-4
@@ -45,8 +45,8 @@ DEFAULTS = {
|
|||||||
'port': 18888,
|
'port': 18888,
|
||||||
},
|
},
|
||||||
'firewall': {
|
'firewall': {
|
||||||
'block_filebrowser': False,
|
'block_filebrowser': True,
|
||||||
'block_director': False,
|
'block_director': True,
|
||||||
'block_postgres': True,
|
'block_postgres': True,
|
||||||
},
|
},
|
||||||
'cache': {
|
'cache': {
|
||||||
@@ -171,17 +171,21 @@ def load_settings(settings_path=None):
|
|||||||
# Backward compatibility: migrate old plaintext password to hash
|
# Backward compatibility: migrate old plaintext password to hash
|
||||||
# This is a one-time migration that hashes the password and removes plaintext
|
# This is a one-time migration that hashes the password and removes plaintext
|
||||||
auth = settings.get('auth', {})
|
auth = settings.get('auth', {})
|
||||||
|
password_migrated = False
|
||||||
if auth.get('password') and not auth.get('password_hash'):
|
if auth.get('password') and not auth.get('password_hash'):
|
||||||
try:
|
try:
|
||||||
from argon2 import PasswordHasher
|
from argon2 import PasswordHasher
|
||||||
ph = PasswordHasher()
|
ph = PasswordHasher()
|
||||||
settings['auth']['password_hash'] = ph.hash(str(auth['password']))
|
settings['auth']['password_hash'] = ph.hash(str(auth['password']))
|
||||||
# Remove plaintext after hashing
|
|
||||||
del settings['auth']['password']
|
del settings['auth']['password']
|
||||||
|
password_migrated = True
|
||||||
logger.info("Migrated plaintext password to Argon2 hash")
|
logger.info("Migrated plaintext password to Argon2 hash")
|
||||||
except ImportError:
|
except ImportError:
|
||||||
logger.error("argon2-cffi not installed. Password hashing unavailable.")
|
logger.error("argon2-cffi not installed. Password hashing unavailable.")
|
||||||
# Fallback: keep plaintext for now but log warning
|
|
||||||
settings['auth']['password_hash'] = None
|
settings['auth']['password_hash'] = None
|
||||||
|
|
||||||
|
if password_migrated:
|
||||||
|
settings['dashboard']['secret_key'] = secrets.token_hex(32)
|
||||||
|
logger.warning("Rotated secret_key to invalidate sessions after password migration")
|
||||||
|
|
||||||
return settings
|
return settings
|
||||||
+1
-1
@@ -24,7 +24,7 @@ def init_auth(app, settings, limiter=None):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
@app.route('/login', methods=['GET', 'POST'])
|
@app.route('/login', methods=['GET', 'POST'])
|
||||||
@limiter.limit("10 per minute") if limiter else lambda f: f
|
@limiter.limit("5 per hour") if limiter else lambda f: f
|
||||||
def login():
|
def login():
|
||||||
if current_user.is_authenticated:
|
if current_user.is_authenticated:
|
||||||
return redirect(url_for('overview'))
|
return redirect(url_for('overview'))
|
||||||
|
|||||||
+16
-6
@@ -317,14 +317,24 @@ def register_routes(app, services, settings):
|
|||||||
def events_page():
|
def events_page():
|
||||||
game_events = []
|
game_events = []
|
||||||
event_logs = []
|
event_logs = []
|
||||||
|
|
||||||
|
def safe_query(table, cols, order_col, limit):
|
||||||
|
try:
|
||||||
|
return db.query(f"SELECT {cols} FROM {table} ORDER BY {order_col} DESC LIMIT {limit}") or []
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error fetching {table}: {e}")
|
||||||
|
return []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
game_events = db.query("SELECT id, event_type, actor_id, actor_name, map, universe_time, x, y, z FROM dune.game_events ORDER BY universe_time DESC LIMIT 50") or []
|
game_events = safe_query("dune.game_events", "*", "universe_time", 50)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.error(f"Error fetching game_events: {e}")
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
event_logs = db.query("SELECT id, event_type, category, function_name, message, event_time, meta FROM dune.event_log ORDER BY event_time DESC LIMIT 100") or []
|
event_logs = safe_query("dune.event_log", "*", "event_time", 100)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.error(f"Error fetching event_logs: {e}")
|
pass
|
||||||
|
|
||||||
return render_template('events.html', game_events=game_events, event_logs=event_logs)
|
return render_template('events.html', game_events=game_events, event_logs=event_logs)
|
||||||
|
|
||||||
# Chat
|
# Chat
|
||||||
|
|||||||
@@ -167,22 +167,56 @@ $FileBrowserPort = "18888"
|
|||||||
$AuthUser = "admin"
|
$AuthUser = "admin"
|
||||||
$AuthPass = ""
|
$AuthPass = ""
|
||||||
|
|
||||||
# Try to detect VM IP from known_hosts
|
# Try to detect VM IP - prioritize local Hyper-V, then local network IPs from known_hosts
|
||||||
$KnownHosts = Join-Path $env:USERPROFILE ".ssh\known_hosts"
|
function Test-IsLocalIP($ip) {
|
||||||
if (Test-Path $KnownHosts) {
|
if ($ip -match '^192\.168\.') { return $true }
|
||||||
$content = Get-Content $KnownHosts
|
if ($ip -match '^10\.') { return $true }
|
||||||
$ips = @()
|
if ($ip -match '^172\.(1[6-9]|2[0-9]|3[0-1])\.') { return $true }
|
||||||
foreach ($line in $content) {
|
return $false
|
||||||
if ($line -match '\b(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\b') {
|
}
|
||||||
$ips += $matches[1]
|
|
||||||
|
# First: try direct Hyper-V detection
|
||||||
|
$vmIp = $null
|
||||||
|
try {
|
||||||
|
$vmAdapter = Get-VMNetworkAdapter -VMName 'dune-awakening' -ErrorAction SilentlyContinue
|
||||||
|
if ($vmAdapter -and $vmAdapter.IPAddresses) {
|
||||||
|
$localIp = $vmAdapter.IPAddresses | Where-Object { Test-IsLocalIP $_ }
|
||||||
|
if ($localIp) {
|
||||||
|
$vmIp = $localIp[0]
|
||||||
|
Write-Host " Detected local Hyper-V VM IP: $vmIp" -ForegroundColor Green
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($ips.Count -gt 0) {
|
} catch { }
|
||||||
$VmHost = $ips[-1]
|
|
||||||
Write-Host " Detected VM IP from SSH history: $VmHost" -ForegroundColor Green
|
if (-not $vmIp) {
|
||||||
|
# Fallback: scan known_hosts and prioritize local IPs
|
||||||
|
$KnownHosts = Join-Path $env:USERPROFILE ".ssh\known_hosts"
|
||||||
|
if (Test-Path $KnownHosts) {
|
||||||
|
$content = Get-Content $KnownHosts
|
||||||
|
$localIps = @()
|
||||||
|
$publicIps = @()
|
||||||
|
foreach ($line in $content) {
|
||||||
|
if ($line -match '\b(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\b') {
|
||||||
|
$ip = $matches[1]
|
||||||
|
if (Test-IsLocalIP $ip) {
|
||||||
|
$localIps += $ip
|
||||||
|
} else {
|
||||||
|
$publicIps += $ip
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($localIps.Count -gt 0) {
|
||||||
|
$vmIp = $localIps[-1]
|
||||||
|
Write-Host " Detected local IP from SSH history: $vmIp" -ForegroundColor Green
|
||||||
|
} elseif ($publicIps.Count -gt 0) {
|
||||||
|
$vmIp = $publicIps[-1]
|
||||||
|
Write-Host " Detected IP from SSH history: $vmIp (verify this is your local VM)" -ForegroundColor Yellow
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($vmIp) { $VmHost = $vmIp }
|
||||||
|
|
||||||
# Auto-detect external IP (try external service first, then local interfaces)
|
# Auto-detect external IP (try external service first, then local interfaces)
|
||||||
try {
|
try {
|
||||||
$HostIp = (Invoke-WebRequest -Uri "https://api.ipify.org" -UseBasicParsing -TimeoutSec 5).Content.Trim()
|
$HostIp = (Invoke-WebRequest -Uri "https://api.ipify.org" -UseBasicParsing -TimeoutSec 5).Content.Trim()
|
||||||
|
|||||||
+12
-23
@@ -3,8 +3,8 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
|
||||||
<title>{% block title %}Dune Awakening Server Dashboard{% endblock %}</title>
|
<title>{% block title %}Dune Awakening Server Dashboard{% endblock %}</title>
|
||||||
|
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -40,8 +40,15 @@
|
|||||||
<div class="update-spinner"></div>
|
<div class="update-spinner"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% block scripts %}{% endblock %}
|
|
||||||
<script>
|
<script>
|
||||||
|
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
|
||||||
|
|
||||||
|
async function csrfFetch(url, options = {}) {
|
||||||
|
options.headers = options.headers || {};
|
||||||
|
options.headers['X-CSRFToken'] = csrfToken;
|
||||||
|
return fetch(url, options);
|
||||||
|
}
|
||||||
|
|
||||||
let updateDismissed = false;
|
let updateDismissed = false;
|
||||||
async function checkForUpdate() {
|
async function checkForUpdate() {
|
||||||
if (updateDismissed) return;
|
if (updateDismissed) return;
|
||||||
@@ -58,7 +65,7 @@
|
|||||||
btn.textContent = 'Checking...';
|
btn.textContent = 'Checking...';
|
||||||
btn.disabled = true;
|
btn.disabled = true;
|
||||||
try {
|
try {
|
||||||
const resp = await fetch('/api/update/check', { method: 'POST' });
|
const resp = await csrfFetch('/api/update/check', { method: 'POST' });
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
if (data.available) {
|
if (data.available) {
|
||||||
document.getElementById('update-banner').style.display = 'flex';
|
document.getElementById('update-banner').style.display = 'flex';
|
||||||
@@ -84,7 +91,7 @@
|
|||||||
banner.style.display = 'none';
|
banner.style.display = 'none';
|
||||||
progress.style.display = 'flex';
|
progress.style.display = 'flex';
|
||||||
try {
|
try {
|
||||||
const resp = await fetch('/api/update/apply', { method: 'POST' });
|
const resp = await csrfFetch('/api/update/apply', { method: 'POST' });
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
statusText.textContent = data.message || 'Applying update...';
|
statusText.textContent = data.message || 'Applying update...';
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
@@ -101,26 +108,8 @@
|
|||||||
}
|
}
|
||||||
setInterval(checkForUpdate, 60000);
|
setInterval(checkForUpdate, 60000);
|
||||||
checkForUpdate();
|
checkForUpdate();
|
||||||
|
|
||||||
// CSRF: Attach token to all non-GET fetch requests
|
|
||||||
(function() {
|
|
||||||
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.content;
|
|
||||||
if (!csrfToken) return;
|
|
||||||
const origFetch = window.fetch;
|
|
||||||
window.fetch = function() {
|
|
||||||
let [resource, config] = arguments;
|
|
||||||
if (!config) config = {};
|
|
||||||
if (!config.headers) config.headers = {};
|
|
||||||
const method = (config.method || 'GET').toUpperCase();
|
|
||||||
if (method !== 'GET' && method !== 'HEAD' && method !== 'OPTIONS') {
|
|
||||||
if (typeof config.headers === 'object') {
|
|
||||||
config.headers['X-CSRFToken'] = csrfToken;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return origFetch(resource, config);
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
</script>
|
</script>
|
||||||
|
{% block scripts %}{% endblock %}
|
||||||
<style>
|
<style>
|
||||||
.update-banner { background: var(--bg-hover); border-bottom: 2px solid var(--accent); padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text); }
|
.update-banner { background: var(--bg-hover); border-bottom: 2px solid var(--accent); padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text); }
|
||||||
.update-actions { display: flex; gap: 8px; }
|
.update-actions { display: flex; gap: 8px; }
|
||||||
|
|||||||
@@ -634,7 +634,7 @@ document.getElementById('btn-clear-world')?.addEventListener('click', async func
|
|||||||
this.disabled = true;
|
this.disabled = true;
|
||||||
this.textContent = 'Clearing...';
|
this.textContent = 'Clearing...';
|
||||||
try {
|
try {
|
||||||
const resp = await fetch('/api/director/character_transfer_clear', { method: 'POST' });
|
const resp = await csrfFetch('/api/director/character_transfer_clear', { method: 'POST' });
|
||||||
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
|
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
|
||||||
document.getElementById('world-status-msg').textContent = 'World status overrides cleared.';
|
document.getElementById('world-status-msg').textContent = 'World status overrides cleared.';
|
||||||
this.textContent = 'Cleared!';
|
this.textContent = 'Cleared!';
|
||||||
@@ -655,7 +655,7 @@ document.getElementById('btn-apply-transfer')?.addEventListener('click', async f
|
|||||||
FreeToTransferCharactersTo: document.getElementById('free-transfer-to').checked
|
FreeToTransferCharactersTo: document.getElementById('free-transfer-to').checked
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const resp = await fetch('/api/director/character_transfer', {
|
const resp = await csrfFetch('/api/director/character_transfer', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify(config)
|
body: JSON.stringify(config)
|
||||||
@@ -674,7 +674,7 @@ document.getElementById('btn-clear-transfer')?.addEventListener('click', async f
|
|||||||
this.disabled = true;
|
this.disabled = true;
|
||||||
this.textContent = 'Clearing...';
|
this.textContent = 'Clearing...';
|
||||||
try {
|
try {
|
||||||
const resp = await fetch('/api/director/character_transfer_clear', { method: 'POST' });
|
const resp = await csrfFetch('/api/director/character_transfer_clear', { method: 'POST' });
|
||||||
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
|
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
|
||||||
document.getElementById('transfer-status-msg').textContent = 'Transfer settings cleared.';
|
document.getElementById('transfer-status-msg').textContent = 'Transfer settings cleared.';
|
||||||
this.textContent = 'Cleared!';
|
this.textContent = 'Cleared!';
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ async function saveFile() {
|
|||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
form.append('path', filePath);
|
form.append('path', filePath);
|
||||||
form.append('content', editor.value);
|
form.append('content', editor.value);
|
||||||
const resp = await fetch('/api/files/save', { method: 'POST', body: form });
|
const resp = await csrfFetch('/api/files/save', { method: 'POST', body: form });
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
if (!data.success) {
|
if (!data.success) {
|
||||||
error.textContent = 'Error: ' + (data.error || 'Failed to save file');
|
error.textContent = 'Error: ' + (data.error || 'Failed to save file');
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ async function loadFiles(path) {
|
|||||||
try {
|
try {
|
||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
form.append('path', path);
|
form.append('path', path);
|
||||||
const resp = await fetch('/api/files/list', { method: 'POST', body: form });
|
const resp = await csrfFetch('/api/files/list', { method: 'POST', body: form });
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
if (!data.success) {
|
if (!data.success) {
|
||||||
list.innerHTML = '';
|
list.innerHTML = '';
|
||||||
|
|||||||
@@ -110,7 +110,7 @@
|
|||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="username">Username</label>
|
<label for="username">Username</label>
|
||||||
<input type="text" id="username" name="username" required autofocus>
|
<input type="text" id="username" name="username" required autofocus>
|
||||||
|
|||||||
@@ -468,7 +468,7 @@ function closeModal(id) {
|
|||||||
async function submitEdit(form, url) {
|
async function submitEdit(form, url) {
|
||||||
const data = new FormData(form);
|
const data = new FormData(form);
|
||||||
try {
|
try {
|
||||||
const resp = await fetch(url, { method: 'POST', body: data });
|
const resp = await csrfFetch(url, { method: 'POST', body: data });
|
||||||
const result = await resp.json();
|
const result = await resp.json();
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
alert('Saved successfully!');
|
alert('Saved successfully!');
|
||||||
@@ -486,7 +486,7 @@ async function submitSpecEdit() {
|
|||||||
const form = document.getElementById('spec-form');
|
const form = document.getElementById('spec-form');
|
||||||
const data = new FormData(form);
|
const data = new FormData(form);
|
||||||
try {
|
try {
|
||||||
const resp = await fetch('/api/edit_tech_knowledge', { method: 'POST', body: data });
|
const resp = await csrfFetch('/api/edit_tech_knowledge', { method: 'POST', body: data });
|
||||||
const result = await resp.json();
|
const result = await resp.json();
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
alert('XP saved!');
|
alert('XP saved!');
|
||||||
@@ -526,7 +526,7 @@ async function submitCurrencyEdit(currencyId) {
|
|||||||
data.append('currency_id', currencyId);
|
data.append('currency_id', currencyId);
|
||||||
data.append('new_balance', newBalance);
|
data.append('new_balance', newBalance);
|
||||||
try {
|
try {
|
||||||
const resp = await fetch('/api/edit_currency', { method: 'POST', body: data });
|
const resp = await csrfFetch('/api/edit_currency', { method: 'POST', body: data });
|
||||||
const result = await resp.json();
|
const result = await resp.json();
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
alert('Currency updated successfully!');
|
alert('Currency updated successfully!');
|
||||||
@@ -543,7 +543,7 @@ async function submitVitalsEdit() {
|
|||||||
const form = document.getElementById('vitals-form');
|
const form = document.getElementById('vitals-form');
|
||||||
const data = new FormData(form);
|
const data = new FormData(form);
|
||||||
try {
|
try {
|
||||||
const resp = await fetch('/api/edit_vitals', { method: 'POST', body: data });
|
const resp = await csrfFetch('/api/edit_vitals', { method: 'POST', body: data });
|
||||||
const result = await resp.json();
|
const result = await resp.json();
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
alert('Vitals updated successfully!');
|
alert('Vitals updated successfully!');
|
||||||
@@ -565,7 +565,7 @@ async function editItem(itemId, field, currentValue) {
|
|||||||
data.append('field', field);
|
data.append('field', field);
|
||||||
data.append('value', newValue);
|
data.append('value', newValue);
|
||||||
try {
|
try {
|
||||||
const resp = await fetch('/api/edit_item', { method: 'POST', body: data });
|
const resp = await csrfFetch('/api/edit_item', { method: 'POST', body: data });
|
||||||
const result = await resp.json();
|
const result = await resp.json();
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
const span = document.getElementById('item-' + field.replace('_', '-') + '-' + itemId);
|
const span = document.getElementById('item-' + field.replace('_', '-') + '-' + itemId);
|
||||||
@@ -584,7 +584,7 @@ async function deleteItem(itemId, templateName) {
|
|||||||
const data = new FormData();
|
const data = new FormData();
|
||||||
data.append('item_id', itemId);
|
data.append('item_id', itemId);
|
||||||
try {
|
try {
|
||||||
const resp = await fetch('/api/delete_item', { method: 'POST', body: data });
|
const resp = await csrfFetch('/api/delete_item', { method: 'POST', body: data });
|
||||||
const result = await resp.json();
|
const result = await resp.json();
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
const row = document.getElementById('item-row-' + itemId);
|
const row = document.getElementById('item-row-' + itemId);
|
||||||
@@ -606,7 +606,7 @@ async function submitAddItem() {
|
|||||||
const form = document.getElementById('add-item-form');
|
const form = document.getElementById('add-item-form');
|
||||||
const data = new FormData(form);
|
const data = new FormData(form);
|
||||||
try {
|
try {
|
||||||
const resp = await fetch('/api/add_item', { method: 'POST', body: data });
|
const resp = await csrfFetch('/api/add_item', { method: 'POST', body: data });
|
||||||
const result = await resp.json();
|
const result = await resp.json();
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
alert('Item added successfully!');
|
alert('Item added successfully!');
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ document.querySelectorAll('.btn-action[data-action="kick"]').forEach(btn => {
|
|||||||
try {
|
try {
|
||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
form.append('player_id', pid);
|
form.append('player_id', pid);
|
||||||
const resp = await fetch('/api/kick_player', { method: 'POST', body: form });
|
const resp = await csrfFetch('/api/kick_player', { method: 'POST', body: form });
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
alert(data.success ? data.message : 'Error: ' + (data.error || 'Failed'));
|
alert(data.success ? data.message : 'Error: ' + (data.error || 'Failed'));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -141,7 +141,7 @@ document.querySelectorAll('.btn-action[data-action="ban"]').forEach(btn => {
|
|||||||
form.append('duration', duration);
|
form.append('duration', duration);
|
||||||
form.append('reason', reason);
|
form.append('reason', reason);
|
||||||
form.append('note', note);
|
form.append('note', note);
|
||||||
const resp = await fetch('/api/ban_player', { method: 'POST', body: form });
|
const resp = await csrfFetch('/api/ban_player', { method: 'POST', body: form });
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
alert(data.success ? `Banned ${name} for ${duration} minutes` : 'Error: ' + (data.error || 'Failed'));
|
alert(data.success ? `Banned ${name} for ${duration} minutes` : 'Error: ' + (data.error || 'Failed'));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -157,7 +157,7 @@ document.querySelectorAll('.btn-action[data-action="unban"]').forEach(btn => {
|
|||||||
try {
|
try {
|
||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
form.append('player_id', pid);
|
form.append('player_id', pid);
|
||||||
const resp = await fetch('/api/unban_player', { method: 'POST', body: form });
|
const resp = await csrfFetch('/api/unban_player', { method: 'POST', body: form });
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
alert(data.success ? `Unbanned ${name}` : 'Error: ' + (data.error || 'Failed'));
|
alert(data.success ? `Unbanned ${name}` : 'Error: ' + (data.error || 'Failed'));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -172,7 +172,7 @@ document.querySelectorAll('.btn-action[data-action="viewban"]').forEach(btn => {
|
|||||||
try {
|
try {
|
||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
form.append('player_id', pid);
|
form.append('player_id', pid);
|
||||||
const resp = await fetch('/api/get_player_ban', { method: 'POST', body: form });
|
const resp = await csrfFetch('/api/get_player_ban', { method: 'POST', body: form });
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
if (data.banned) {
|
if (data.banned) {
|
||||||
alert(`Ban Info for ${name}:\n\nDuration: ${data.duration} minutes\nReason: ${data.reason}\nNote: ${data.note || 'None'}\nBanned: ${data.banned_at}\nExpires: ${data.expires_at}`);
|
alert(`Ban Info for ${name}:\n\nDuration: ${data.duration} minutes\nReason: ${data.reason}\nNote: ${data.note || 'None'}\nBanned: ${data.banned_at}\nExpires: ${data.expires_at}`);
|
||||||
@@ -191,7 +191,7 @@ document.querySelectorAll('.btn-action[data-action="history"]').forEach(btn => {
|
|||||||
try {
|
try {
|
||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
form.append('player_id', pid);
|
form.append('player_id', pid);
|
||||||
const resp = await fetch('/api/get_player_history', { method: 'POST', body: form });
|
const resp = await csrfFetch('/api/get_player_history', { method: 'POST', body: form });
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
if (data.history && data.history.length > 0) {
|
if (data.history && data.history.length > 0) {
|
||||||
let msg = `Action History for ${name}:\n\n`;
|
let msg = `Action History for ${name}:\n\n`;
|
||||||
@@ -225,7 +225,7 @@ document.querySelectorAll('.ip-cell').forEach(cell => {
|
|||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
form.append('player_id', pid);
|
form.append('player_id', pid);
|
||||||
form.append('ip_address', newIp);
|
form.append('ip_address', newIp);
|
||||||
const resp = await fetch('/api/set_player_ip', { method: 'POST', body: form });
|
const resp = await csrfFetch('/api/set_player_ip', { method: 'POST', body: form });
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
this.textContent = newIp || '—';
|
this.textContent = newIp || '—';
|
||||||
@@ -244,7 +244,7 @@ async function detectIps() {
|
|||||||
try {
|
try {
|
||||||
const btn = document.querySelector('button[onclick="detectIps()"]');
|
const btn = document.querySelector('button[onclick="detectIps()"]');
|
||||||
if (btn) { btn.disabled = true; btn.textContent = 'Detecting...'; }
|
if (btn) { btn.disabled = true; btn.textContent = 'Detecting...'; }
|
||||||
const resp = await fetch('/api/detect_player_ips', { method: 'POST' });
|
const resp = await csrfFetch('/api/detect_player_ips', { method: 'POST' });
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
console.log('IP detection:', data.message);
|
console.log('IP detection:', data.message);
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ document.querySelectorAll('.btn-action').forEach(btn => {
|
|||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
form.append('deployment', deploy);
|
form.append('deployment', deploy);
|
||||||
form.append('action', action);
|
form.append('action', action);
|
||||||
const resp = await fetch('/server/action', { method: 'POST', body: form });
|
const resp = await csrfFetch('/server/action', { method: 'POST', body: form });
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
outputText.textContent = data.output || (data.success ? 'Done' : 'Failed');
|
outputText.textContent = data.output || (data.success ? 'Done' : 'Failed');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -298,7 +298,7 @@ document.querySelectorAll('.partition-btn').forEach(btn => {
|
|||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
form.append('deployment', deploy);
|
form.append('deployment', deploy);
|
||||||
form.append('action', 'restart');
|
form.append('action', 'restart');
|
||||||
const resp = await fetch('/server/action', { method: 'POST', body: form });
|
const resp = await csrfFetch('/server/action', { method: 'POST', body: form });
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
outputText.textContent = data.output || (data.success ? 'Restart initiated' : 'Failed');
|
outputText.textContent = data.output || (data.success ? 'Restart initiated' : 'Failed');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -344,7 +344,7 @@ async function bgAction(action, btn) {
|
|||||||
const url = action === 'update' ? '/server/battlegroup/update' : '/server/battlegroup/action';
|
const url = action === 'update' ? '/server/battlegroup/update' : '/server/battlegroup/action';
|
||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
form.append('action', action);
|
form.append('action', action);
|
||||||
const resp = await fetch(url, { method: 'POST', body: form });
|
const resp = await csrfFetch(url, { method: 'POST', body: form });
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
pre.textContent = data.output || (data.success ? `${action} completed successfully` : `Failed: ${data.output}`);
|
pre.textContent = data.output || (data.success ? `${action} completed successfully` : `Failed: ${data.output}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -435,7 +435,7 @@ async function loadFwStatus() {
|
|||||||
try {
|
try {
|
||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
form.append('port', port);
|
form.append('port', port);
|
||||||
const resp = await fetch('/server/firewall/' + action, { method: 'POST', body: form });
|
const resp = await csrfFetch('/server/firewall/' + action, { method: 'POST', body: form });
|
||||||
const result = await resp.json();
|
const result = await resp.json();
|
||||||
outputText.textContent = result.output || (result.success ? 'Done' : 'Failed');
|
outputText.textContent = result.output || (result.success ? 'Done' : 'Failed');
|
||||||
await loadFwStatus();
|
await loadFwStatus();
|
||||||
|
|||||||
Reference in new issue
Block a user